(function(app){
	app
		.controller("photo_mainCtrl",["$scope","myFactory",'$http','$stateParams','$interval','$state',"$q",'$timeout','$location','$ionicHistory',function($scope,myFactory,$http,$stateParams,$interval,$state,$q,$timeout,$location,$ionicHistory){
			//接收参数
			var itemId = $stateParams.itemId;//变更项目ID
			var chdrnum01 =  $stateParams.chdrnum01; //保单号
			$scope.chdrnum01=$stateParams.chdrnum01; //保单号
			var chdrcoy = $stateParams.chdrcoy; //保单公司号码
			var signMainData=$stateParams.signMainData;//用于返回

			$scope.photoMainData=$stateParams.photoMainData;
			var photoMainData = $stateParams.photoMainData;
			var strItemIds=photoMainData.strItemIds;
			//判断投保人被保人是否同一个人，是的话，即使更新了10变更项，也仍然不需要被保人签名 add by csf start
			var isSamePerson = $stateParams.isSamePerson;
			//判断投保人被保人是否同一个人，是的话，即使更新了10变更项，也仍然不需要被保人签名 add by csf end
			//页面数据
			$scope.photoRule=photoMainData.photoRule;
			var photoRule=photoMainData.photoRule;
			$scope.policy=photoMainData.policy;
			var policy=photoMainData.policy;
			$scope.holderIdDate=photoMainData.holderIdDate;
			var holderIdDate=photoMainData.holderIdDate;
			$scope.insuredIdDate=photoMainData.insuredIdDate;
			var insuredIdDate=photoMainData.insuredIdDate;
			$scope.benefiIdDate=photoMainData.benefiIdDate;
			var benefiIdDate=photoMainData.benefiIdDate;

			// S2023020825099 TX FaceID add by lvjg 20230625 start
			var idTypeAndCharge = photoMainData.idTypeAndCharge;
			var face_ow_name = idTypeAndCharge.ow_name;
			var face_ow_idno = idTypeAndCharge.ow_idNo;
			var face_lf_name = idTypeAndCharge.lf_name;
			var face_lf_idno = idTypeAndCharge.lf_idNo;
			console.log("face_ow_name:" + face_ow_name + ", face_ow_idno:" + face_ow_idno);
			console.log("face_lf_name:" + face_lf_name + ", face_lf_idno:" + face_lf_idno);
			// ##S2023020825099 TX FaceID add by lvjg 20230625 end

			var sysDate=photoMainData.sysDate;



			var content_id = "01" ;
			var mark=1;//图片层标识 自增长
			//var backTgt ="<%=backTgt %>"; //是否为下一个页面返回
			var timeOutPhoto="N";

			var policyHolderNum=photoRule.policyHolderNum;
			var policyHolderIDNum=photoRule.policyHolderIDNum;
			var insuredNum=photoRule.insuredNum;
			var insuredIDNum=photoRule.insuredIDNum;
			var benefiNum=photoRule.benefiNum;
			var benefiIDNum=photoRule.benefiIDNum;
			var bankNum=photoRule.bankNum;
			var otherNum=photoRule.otherNum;
			var token=sessionStorage.getItem("token");
			var tokenEndAuthorId="A";
			
			var maxTime = 500;//3*60;//倒计时时间
			var timer;
			//PC端测试数据
			var testVal="R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7";

			//拍照控制
			var curentPtId="";
			var curentPtTypeName="";
			//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
			var curentPtRole="";
			var appVersionPlat="";
			var verifyStatusOwFlag=false;
			var verifyStatusLfFlag=false;
			//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 start
			var stallShow = true;
			var isShowInsurPtFace = false;//标识被保人人脸是否已经显示了
			var isShowInsurPtId = false;//标识被保人留影界面是否已经显示了
			//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 end
			$scope.isPhotoOpenFlag=true;
			$scope.isPhotoOCRFlag=true;
			//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
			
			//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180729 begin
			var idTypeAndCharge=photoMainData.idTypeAndCharge;
			var isNewHighRefundFeeFlag = "";
			if(idTypeAndCharge!=undefined && idTypeAndCharge!=null && idTypeAndCharge!=""){
				isNewHighRefundFeeFlag=idTypeAndCharge.isNewHighRefundFeeFlag;
				console.log("isNewHighRefundFeeFlag="+isNewHighRefundFeeFlag);
			}
			//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180729 end

			$scope.otherPtData=[];
			var otherPtData=[];
			var otherPtAddId=0;

			$scope.benefiIdPtData=[];
			var benefiIdPtData=[];
			var benefiIdPtAddId=0;
			
			$scope.data = {
				holderY: false,
				holderN: false,
				insuredY: false,
				insuredN: false,

				showHolderInfoFlag: false,
				showInsuredInfoFlag: false,
				showBenefiInfoFlag: false,
				showProfitInfoFlag: false, //受益人信息展示标记
				browserType : "", //客户端设备类型

				timeRest: null,
				textFlag: true,
				timePhoto: null,

				radioFlag: {
					holder: true,
					recognizee: true
				}
			};


			//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
			var appVersionFlag = myFactory.getBrowserType();
			$scope.data.browserType = appVersionFlag;
			if(photoMainData.ow_idTypeName=="身份证"){
				$("#holderIdDate").attr("disabled","disabled");
			    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
                $("#holderIdDateStart").attr("disabled","disabled");
			    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				$("#holderIdDateType").attr("disabled","disabled");
				$("#holderCreType").css("color","#C9C9C9");
				if ( appVersionFlag != 'IOS'){
					 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
					$("#holderIdDateStart").css("color","#C9C9C9");
					 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
					$("#holderIdDate").css("color","#C9C9C9");
				}
			}
			if(photoMainData.lf_idTypeName=="身份证"){
				$("#insuredIdDate").attr("disabled","disabled");
				 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
				$("#insuredIdDateStart").attr("disabled","disabled");
				 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				$("#insuredIdDateType").attr("disabled","disabled");
				$("#insuredCreType").css("color","#C9C9C9");
				if( appVersionFlag != 'IOS'){
					 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
					$("#insuredIdDateStart").css("color","#C9C9C9");
					 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
					$("#insuredIdDate").css("color","#C9C9C9");
					
				}
			}
			//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
			
			
			$scope.initLoad = function(){
				//initSign();//拍照初始化
				//startPhotoIterval();//拍照限时
				//idDateInit();//证件有效期初始化
				$scope.startPhotoIterval();
				idDateInit();//证件有效期初始化
				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180729 begin
				$scope.item08IdPicIterval();
				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180729 end
			}

			var imgContentId={//影像对应的contextid
				policyHolderPt:500,
				policyHolderIdPt:501,
				insuredPt:502,
				insuredIdPt:503,
				benefiPt:504,
				benefiIdPt:505,
				bankPt:506,
				otherPt:507
			}

			function idDateInit(){
				var holderIdDateType= $("#holderIdDateType");
				var holderIdDate= $("#holderIdDate");
				 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
				var holderIdDateStart= $("#holderIdDateStart");
				var insuredIdDateStart= $("#insuredIdDateStart");
				var benefiIdIdDateStart= $("#benefiIdDateStart");
				 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				var insuredIdDateType= $("#insuredIdDateType");
				var insuredIdDate =$("#insuredIdDate");

				var benefiIdDateType= $("#benefiIdDateType");
				var benefiIdIdDate= $("#benefiIdDate");

				if(holderIdDateType && holderIdDateType.val()=='1'){
					holderIdDate.val("");
					holderIdDate.attr("disabled",true);
				}

				if(insuredIdDateType && insuredIdDateType.val()=='1'){
					insuredIdDate.val("");
					insuredIdDate.attr("disabled",true);
				}

				if(benefiIdDateType && benefiIdDateType.val()=='1'){
					benefiIdIdDate.val("");
					benefiIdIdDate.attr("disabled",true);
				}
			}

			/******************页面部分显示逻辑处理begin**************/
			$scope.showPolicyHolderPtFlag=false;
			$scope.showPolicyHolderIdPtFlag=false;
			$scope.showInsuredPtFlag=false;
			$scope.showInsuredIdPtFlag=false;
			$scope.showBenefiPtFlag=false;
			$scope.showBenefiIdPtFlag=false;//权益人
			$scope.showProfitIdPtFlag=false;//受益人
			$scope.showBankPtFlag=false;
			$scope.showOtherPtFlag=false;
			/*$scope.showPolicyHolderPtFlag=true;
			$scope.showPolicyHolderIdPtFlag=true;
			$scope.showInsuredPtFlag=true;
			$scope.showInsuredIdPtFlag=true;
			$scope.showBenefiPtFlag=true;
			$scope.showBenefiIdPtFlag=true;//权益人
			$scope.showProfitIdPtFlag=true;//受益人
			$scope.showBankPtFlag=true;
			$scope.showOtherPtFlag=true;*/

			var checkFlag10=checkIsItemIdType("10");
			//投/被保人 投/被保人证件
			if(photoRule.policyHolder=='Y'){
				$scope.showPolicyHolderPtFlag=true;//显示
				
				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
			/*	if(photoMainData.ow_idTypeName=="身份证" && "Y"==isNewHighRefundFeeFlag){
					facePageChange('div_policyHolderFs','div_policyHolderPt','checkImg_500');
				}*/
				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
				//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 start
				if("Y"==isNewHighRefundFeeFlag || stallShow){
					facePageChange('div_policyHolderFs','div_policyHolderPt','checkImg_500');
				}
				//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 end
			}
			if(photoRule.policyHolderID=='Y'){
				
				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
				//$("#photoZoneTbrId_a").attr('ng-click','scanIdcardPictures(\'501a\',\'policyHolderIdPt\',\'OW\')');
				//if(photoMainData.ow_idTypeName=="身份证"){
					//$("#photoZoneTbrId_a").attr('ng-click',"scanIdcardPictures('501a','policyHolderIdPt','OW')");
					//$("#photoZoneTbrId_b").attr('ng-click',"scanIdcardPictures('501b','policyHolderIdPt','OW')");
				//}
				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
				
				$scope.showPolicyHolderIdPtFlag=true;//显示
				$scope.data.showHolderInfoFlag=true;//显示

				if(policy.cownnum01==policy.lifcnum01){
					//$scope.policyHolderName="投/被保险人";
					$scope.policyHolderName="投保人";//20170816:要对显示多种签名者名称进行调整需求，rqyang
					$("#isSamePerson_a").val("Y");
				}else{
					$scope.policyHolderName="投保人";
					$("#isSamePerson_a").val("N");
				}

				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
				var ow_availDataType="";
				//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start 
                var ow_availDataStart="";
				//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				var ow_availDataClose="";
				if(checkFlag10=="Y"){//含有变更项10 则设置证件有效期为变更后的类型
					ow_availDataType=photoMainData.ow_availDataType;//1 - 终身 2 - 年期 3 - 缺省
                    // S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start 
					ow_availDataStart=photoMainData.ow_availDataStart;   //有效期起始日
					//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end 
					ow_availDataClose=photoMainData.ow_availDataClose;
				}else{
					ow_availDataType=holderIdDate.flag01;//1 - 终身 2 - 年期 3 - 缺省
					// S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start 
					ow_availDataStart=holderIdDate.dateup03;
					// S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end 
					ow_availDataClose=holderIdDate.dateup01;
				}
				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
				
				$("#holderIdDateType").val(ow_availDataType);
				$scope.holderIdDateTypeSelect = ow_availDataType;
				var options_holder =$("#holderIdDateType option:selected");
				$scope.holderCreTypeName=options_holder.text();

				if(ow_availDataType=='2'){
					//var ow_availDataClose=holderIdDate.dateup01;
					// S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start  
					if(ow_availDataStart!="" && ow_availDataStart!=null && ow_availDataStart!=undefined){
						$scope.photoMainData.ow_availDataStart=ow_availDataStart;
						myFactory.initDateUtil('holderIdDateStart',DateTools(ow_availDataStart));
					}else{
						myFactory.initDateUtil('holderIdDateStart','');
					}
					// S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
					if(ow_availDataClose!="" && ow_availDataClose!=null && ow_availDataClose!=undefined){
						$scope.photoMainData.ow_availDataClose=ow_availDataClose;
						myFactory.initDateUtil('holderIdDate',DateTools(ow_availDataClose));
					}else{
						myFactory.initDateUtil('holderIdDate','');
					}
				}else{
					// S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start 
					myFactory.initDateUtil('holderIdDateStart',DateTools(ow_availDataStart));
					// S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
					myFactory.initDateUtil('holderIdDate','');
				}
			}
			//S2018110706102 - 移动保全受理含“10-更改个人资料”的多项变更，客户签名留影缺失问题   add by csf20181119 start
			//被保人 投/被保人证件
			//var checkFlag10=checkIsItemIdType("10");
			if(photoRule.insured=='Y'){
				//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 start
				    isShowInsurPtId = true;
				  //S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 end
					$scope.showInsuredPtFlag=true;//显示
					
					//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
					if("Y"==isNewHighRefundFeeFlag || stallShow){
						console.log('被保人人脸识别');
						isShowInsurPtFace = true;
						facePageChange('div_insuredFs','div_insuredPt','checkImg_502');
					}
					//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
						//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 end
				}
				//else{S2018110706102 - 移动保全受理含“10-更改个人资料”的多项变更，客户签名留影缺失问题 注释掉
			var flag = sessionStorage.getItem("isChange_insured_item10");
			//增加判断被保人年龄大小是否超过18岁 add by csf 20181121 start 
			var birthday = policy.rnBirthday +"";
			var tempdate = birthday.substr(0,4) + "-" + birthday.substr(4,2) + "-" + birthday.substr(6,2);
			var age = getAge(tempdate);
					//移动保全1.0规则，如只变更投保人信息，则只需要投保人签名及身份证件留影，投保人与被保险人同时核对身份信息是否一致。
					//当变更被保险人或同时变更投保人与被保险人，则才同时需要投保人与被保险人同时签名及身份证件留影。
			//判断投保人被保人是否同一个人，是的话，即使更新了10变更项，也仍然不需要被保人签名 add by csf start
					if(1==flag && age >= 18 &&!isSamePerson ){
						//判断投保人被保人是否同一个人，是的话，即使更新了10变更项，也仍然不需要被保人签名 add by csf end
			//增加判断被保人年龄大小是否超过18岁 add by csf 20181121 end
						//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 start
						if (!isShowInsurPtId){
							$scope.showInsuredPtFlag=true;//显示
						}
						//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 end
						//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
						if("Y"==isNewHighRefundFeeFlag || stallShow){
							console.log('被保人人脸识别');
							//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 start
							if (!isShowInsurPtFace){
								//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 end
								facePageChange('div_insuredFs','div_insuredPt','checkImg_502');
							}
						}
						//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
					}
					//S2018110706102 - 移动保全受理含“10-更改个人资料”的多项变更，客户签名留影缺失问题   add by csf20181119 end
			//checkFlag10
			//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
			/*var itemIdCard10_ow=photoMainData.itemIdCard10_ow;
			var itemIdCard10_lf=photoMainData.itemIdCard10_lf;
			setItem10Base64Img(itemIdCard10_ow,"ow");
			setItem10Base64Img(itemIdCard10_lf,"lf");*/
			if(checkFlag10=="Y"){//含有变更项10 则做自动判断证件OCR
				//alert("checkFlag10"+checkFlag10);
				autoSetItem10IdPic();
			}
			//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
			//变更非10时被保人有效期没显示 add by csf start
//			if(photoRule.insuredID=='Y'){
//				$scope.showInsuredIdPtFlag=true;//显示
//				$scope.data.showInsuredInfoFlag=true;
//				
//				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
//				var lf_availDataType=photoMainData.lf_availDataType;//1 - 终身 2 - 年期 3 - 缺省
//				var lf_availDataClose=photoMainData.lf_availDataClose;
//				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
//				
//				//$("#insuredIdDateType").val(insuredIdDate.flag01);
//				$("#insuredIdDateType").val(lf_availDataType);
//				//$scope.insuredIdDateTypeSelect = insuredIdDate.flag01;
//				$scope.insuredIdDateTypeSelect = lf_availDataType;
//				var options_insured =$("#insuredIdDateType option:selected");
//				$scope.insuredCreTypeName=options_insured.text();
//				myFactory.initDateUtil('insuredIdDate','');
//				
//				if(lf_availDataType=='2'){
//					if(lf_availDataClose!="" && lf_availDataClose!=null && lf_availDataClose!=undefined){
//						$scope.photoMainData.lf_availDataClose=lf_availDataClose;
//						myFactory.initDateUtil('insuredIdDate',DateTools(lf_availDataClose));
//					}else{
//						myFactory.initDateUtil('insuredIdDate','');
//					}
//				}
//			}
			if(photoRule.insuredID=='Y'){
				//S2018091005428-移动保全人脸核身优化需求 start
//				if(checkFlag10=="N"){
				//S2018091005428-移动保全人脸核身优化需求 end
					$scope.showInsuredIdPtFlag=true;//显示
					$scope.data.showInsuredInfoFlag=true;
					$("#insuredIdDateType").val(insuredIdDate.flag01);
					//$scope.insuredIdDateTypeSelect = insuredIdDate.flag01;
					$scope.insuredIdDateTypeSelect = insuredIdDate.flag01;
					var options_insured =$("#insuredIdDateType option:selected");
					$scope.insuredCreTypeName=options_insured.text();
				 	//myFactory.initDateUtil('insuredIdDate','');
					if(insuredIdDate.flag01=='2'){
					    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
						var lf_availDataStart=insuredIdDate.dateup03;
						if(lf_availDataStart!="" && lf_availDataStart!=null && lf_availDataStart!=undefined){
							
							if(checkFlag10=="N"){
								$scope.photoMainData.lf_availDataStart=lf_availDataStart;
							}
							
							myFactory.initDateUtil('insuredIdDateStart',DateTools(lf_availDataStart));
						}else{
							myFactory.initDateUtil('insuredIdDateStart','');
						}
						//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end 
						var lf_availDataClose=insuredIdDate.dateup01;
						if(lf_availDataClose!="" && lf_availDataClose!=null && lf_availDataClose!=undefined){
							//S2018091005428-移动保全人脸核身优化需求 start
							if(checkFlag10=="N"){
								//S2018091005428-移动保全人脸核身优化需求 end
								$scope.photoMainData.lf_availDataClose=lf_availDataClose;
							}
							
							myFactory.initDateUtil('insuredIdDate',DateTools(lf_availDataClose));
						}else{
							myFactory.initDateUtil('insuredIdDate','');
						}
					}else{
						myFactory.initDateUtil('insuredIdDate','');
					}
//				}
			}
			//变更非10时被保人有效期没显示 add by csf end
				//else{
//					var flag = sessionStorage.getItem("isChange_insured_item10");
//					//移动保全1.0规则，如只变更投保人信息，则只需要投保人签名及身份证件留影，投保人与被保险人同时核对身份信息是否一致。
//					/**S2018110706102 - 移动保全受理含“10-更改个人资料”的多项变更，客户签名留影缺失问题 add by csf 20181114  start
//					对于多项变更项的处理,如果被保人信息没有被修改则判断是否为多项变更，是的话就显示被保人信息
//					 */
//					var isManyItes = checkMany();
////					if(1==flag){
//					//检测是否是多项变更项 add by csf 20181114 start
//					//对于多项变更项的处理,如果被保人信息没有被修改则判断是否为多项变更，是的话就显示被保人信息
//						if(1==flag || isManyItes){
//						$scope.showInsuredIdPtFlag=true;//显示
//						$scope.data.showInsuredInfoFlag=true;
//						
//						//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
//						var lf_availDataType=photoMainData.lf_availDataType;//1 - 终身 2 - 年期 3 - 缺省
//						var lf_availDataClose=photoMainData.lf_availDataClose;
//						//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
//						
//						//$("#insuredIdDateType").val(insuredIdDate.flag01);
//						$("#insuredIdDateType").val(lf_availDataType);
//						//$scope.insuredIdDateTypeSelect = insuredIdDate.flag01;
//						$scope.insuredIdDateTypeSelect = lf_availDataType;
//						var options_insured =$("#insuredIdDateType option:selected");
//						$scope.insuredCreTypeName=options_insured.text();
//						myFactory.initDateUtil('insuredIdDate','');
//						
//						if(lf_availDataType=='2'){
//							if(lf_availDataClose!="" && lf_availDataClose!=null && lf_availDataClose!=undefined){
//								$scope.photoMainData.lf_availDataClose=lf_availDataClose;
//								myFactory.initDateUtil('insuredIdDate',DateTools(lf_availDataClose));
//							}else{
//								myFactory.initDateUtil('insuredIdDate','');
//							}
//						}
//					}
//				}
//			}
			//判断被保人信息是否被更改
			var flag = sessionStorage.getItem("isChange_insured_item10");
			//判断投保人被保人是否同一个人，是的话，即使更新了10变更项，也仍然不需要被保人签名 add by csf start
			if(1==flag && !isSamePerson){
				//判断投保人被保人是否同一个人，是的话，即使更新了10变更项，也仍然不需要被保人签名 add by csf end
				$scope.showInsuredIdPtFlag=true;//显示
				$scope.data.showInsuredInfoFlag=true;
				
				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
				var lf_availDataType=photoMainData.lf_availDataType;//1 - 终身 2 - 年期 3 - 缺省
				//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
				var lf_availDataStart=photoMainData.lf_availDataStart;
				//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				var lf_availDataClose=photoMainData.lf_availDataClose;
				//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
				
				//$("#insuredIdDateType").val(insuredIdDate.flag01);
				$("#insuredIdDateType").val(lf_availDataType);
				//$scope.insuredIdDateTypeSelect = insuredIdDate.flag01;
				$scope.insuredIdDateTypeSelect = lf_availDataType;
				var options_insured =$("#insuredIdDateType option:selected");
				$scope.insuredCreTypeName=options_insured.text();
				myFactory.initDateUtil('insuredIdDate','');
				//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
                myFactory.initDateUtil("insuredIdDateStart","");
                if(lf_availDataType=='2'){
					if(lf_availDataStart!="" && lf_availDataStart!=null && lf_availDataStart!=undefined){
						$scope.photoMainData.lf_availDataStart=lf_availDataStart;
						myFactory.initDateUtil('insuredIdDateStart',DateTools(lf_availDataStart));
					}else{
						myFactory.initDateUtil('insuredIdDateStart','');
					}
				}
				//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				
				if(lf_availDataType=='2'){
					if(lf_availDataClose!="" && lf_availDataClose!=null && lf_availDataClose!=undefined){
						$scope.photoMainData.lf_availDataClose=lf_availDataClose;
						myFactory.initDateUtil('insuredIdDate',DateTools(lf_availDataClose));
					}else{
						myFactory.initDateUtil('insuredIdDate','');
					}
				}
			}
			//S2018110706102 - 移动保全受理含“10-更改个人资料”的多项变更，客户签名留影缺失问题 add by csf 20181114  end  			
			
			//权益人
			if(photoRule.benefi=='Y'){
				var checkFlag08=checkIsItemIdType("08");
				if(checkFlag08=="N"){
					$scope.showBenefiPtFlag=true;//显示权益人留影
				}
			}

			//权益人、受益人 证件留影
			//if(1==1){
			if(photoRule.benefiID=='Y'){
				var typeResult=checkIsBenefiItemIdType();
				if(typeResult=="N"){
					$scope.showBenefiIdPtFlag=true;//显示权益人证件
				}else if(typeResult=="Y_08_S"){
					$scope.showProfitIdPtFlag=true;//显示受益人证件
				}else if(typeResult=="Y_08_B"){
					$scope.showBenefiIdPtFlag=true;//显示权益人证件
				}else if(typeResult=="Y_08_D"){
					$scope.showBenefiIdPtFlag=true;//显示权益人证件
					$scope.showProfitIdPtFlag=true;//显示受益人证件
				}

				//受益人证件留影：动态生成，名字获取仅仅来自受益人变更功能模块录入数据
				var checkFlag08=checkIsItemIdType("08");//存在身故受益人则获取名字信息
				if(checkFlag08=="Y") {//身故受益人
					//数据初步设计：可以将要变更为显示对应的受益人名字在前面存入sessionStorage缓存中进行处理
					var benefitList = photoMainData.benefitList;
					if(benefitList.length>0){
						$scope.data.showProfitInfoFlag = true;
						for(var i = 0; i < benefitList.length; i++){
							var name = benefitList[i].name;//姓名
							var idNo = benefitList[i].idNo;//证件号码
							var idType = benefitList[i].idType;
							var IDTypeCN = benefitList[i].idtypeCN;//证件类型
							var availDataType = benefitList[i].availDataType;//有效期类型
							var availDataTypeCN = benefitList[i].availDataTypeCN;
							var availDataStart = benefitList[i].availDataStart;//有效期起始日
							var availDataClose = availDataType == '1' ? '' : benefitList[i].availDataClose;//有效期截至日
							var ida='505_a' + benefiIdPtAddId;
							var idb='505_b' + benefiIdPtAddId;
							var picVal = {
								'keyId': benefiIdPtAddId,
								'name': name,
								'ida': ida,
								'idb': idb,
								'idType': idType,
								'IDTypeCN': IDTypeCN,
								'idNo': idNo,
								'availDataType': availDataType,
								'availDataTypeCN': availDataTypeCN,
								'availDataStart': availDataStart,
								'availDataClose': availDataClose,
								'checkedY' : false,
								'checkedN' : false
							};
							benefiIdPtData.push(picVal);
							benefiIdPtAddId++;
						}
						$scope.benefiIdPtData=benefiIdPtData;
						var benefiIdPtDataJson = JSON.stringify(benefiIdPtData);
						console.log("当前benefiIdPtData:"+benefiIdPtDataJson);
						$scope.benefiIdPtData=benefiIdPtData;
					}
				}
			}
			if(photoRule.benefiID=='Y'&& photoMainData.showBenefiIdDate!='N'){
				$scope.data.showBenefiInfoFlag=true;
				var flag01="";
				if(benefiIdDate!=null && benefiIdDate!=undefined && benefiIdDate!=""){
					flag01=benefiIdDate.flag01;
				}else{//赋给默认选择第一个
					flag01="2";
				}
				$("#benefiIdDateType").val(flag01);
				$scope.benefiIdDateTypeSelect =flag01;
				var options_benefi =$("#benefiIdDateType option:selected");
				$scope.benefiCreTypeName=options_benefi.text();
				myFactory.initDateUtil('benefiIdDate','');
			}

			//银行卡
			if(photoRule.bank=='Y'){
				$scope.showBankPtFlag=true;//显示
			}
			//其他随附资料
			if(photoRule.other=='Y' ||checkFlag10=="Y" ){
				$scope.showOtherPtFlag=true;//显示
			}
			
			//拍照函数
			$scope.takePictures = function(context_id,typeName){
				if($scope.isPhotoOpenFlag){
					$scope.isPhotoOpenFlag=false;
					setTimeout(function() {
						$scope.isPhotoOpenFlag=true;
					}, 350);
				}else{
					return false;
				}
				/*var appVersionFlag = myFactory.getBrowserType();
				console.log("appVersionFlag:"+appVersionFlag);
				var data = {};
				if(appVersionFlag=="Android" || appVersionFlag=="Browser"){//安卓版本未有解决新接口，需分离平台调用
					data = {
							//title : '投保人（留影）',
							width : '960',
							height : '720',
							//mono : 'true',//bool 此选项无效
							mono : 'false',//bool 此选项无效[false支持彩色图片]
							quality : '50',//int 0~100 推荐85
							//quality : '5',
							openFromGallery : 'false',//是否从相册选择照片
							//openFromGallery : 'true',//是否从相册选择照片
							//businessType : '2'
							businessType : '0'//去除“请拍摄人脸”
					};
				}else if(appVersionFlag=="IOS"){
					var openFromGallery=false; //true:从相册中选择，false:拍照
					data = {
							openFromGallery : openFromGallery,//是否从相册选择照片：true:从相册中选择，false:拍照
							imgType : 'OtherPhoto'//固定值，千万不要改动
					};
				}*/
				var openFromGallery=false; //true:从相册中选择，false:拍照
				var data = {
						openFromGallery : openFromGallery,//是否从相册选择照片：true:从相册中选择，false:拍照
						imgType : 'OtherPhoto'//固定值，千万不要改动
				};

				if(curentPtId!=""){
					curentPtId="";
					curentPtTypeName="";
				}
				curentPtId=context_id;
				curentPtTypeName=typeName;

				if(context_id=='507'){
					if(maxTime==0){//如果超出时间限制测不能再拍照
						myFactory.alert('','拍摄超时，请返回上一步重新处理','info');
						return false;
					}
					//其他资料
					if(otherPtData.length==10){//其他资料（最多10张）
						/*S2018122906735移动保全新增变更项目及功能的优化需求 update by mqz 20200901 start*/
						if(strItemIds.indexOf('15')>-1 || strItemIds.indexOf('29')>-1 || strItemIds.indexOf('30')>-1 ){
							myFactory.alert('','体检报告最多10张！','info');
							return false;
						}else{
							myFactory.alert('','其他资料最多10张！','info');
							return false;
						}
						/*S2018122906735移动保全新增变更项目及功能的优化需求 update by mqz 20200901 end*/
					}
					
					var appVersionFlag = myFactory.getBrowserType();
					console.log("appVersionFlag:"+appVersionFlag);
					if(appVersionFlag=="Android"){
					}else if(appVersionFlag=="IOS"){
					}else if(appVersionFlag=="Browser"){
						console.log("当前otherPtData.length:"+otherPtData.length);
						if(otherPtData.length==0){//重置动态资源变量
							otherPtAddId=0;
						}
						var otherPtDataJson = JSON.stringify(otherPtData);
						console.log("当前otherPtData:"+otherPtDataJson);

						//数组参数
						var keyId=otherPtAddId;
						var url='data:image/gif;base64,'+testVal;
						var ido=otherPtAddId;
						var idPt=testVal;
						var picVal={'keyId':keyId,'url': url,'ido':ido,'idPt':idPt};

						otherPtData.push(picVal);
						otherPtAddId++;
						$scope.otherPtData=otherPtData;

						/*console.log("---------------------add begin-----------------------");
						console.log("点击新增后otherPtData.length:"+otherPtData.length);
						var otherPtDataJson = JSON.stringify(otherPtData);
						console.log("点击新增后otherPtData:"+otherPtDataJson);

						var otherPtDataTemp=$scope.otherPtData;
						console.log("点击新增后otherPtDataTemp.length:"+otherPtDataTemp.length);
						var otherPtDataTempJson = JSON.stringify(otherPtDataTemp);
						console.log("点击新增后otherPtDataTemp:"+otherPtDataTempJson);
						console.log("---------------------add end-----------------------");*/

						return false;
					}else{
					}
					/****************测试数据*****************/
				}else{
					var photoValTemp=$("#"+typeName+"_"+context_id).val();
					if(photoValTemp!=""){
						console.log("there ware a pic");
						return false;
					}
					
					if(maxTime==0){//如果超出时间限制测不能再拍照
						myFactory.alert('','拍摄超时，请返回上一步重新处理','info');
						return false;
					}
					
					var appVersionFlag = myFactory.getBrowserType();
					console.log("appVersionFlag:"+appVersionFlag);
					if(appVersionFlag=="Android"){
					}else if(appVersionFlag=="IOS"){
					}else if(appVersionFlag=="Browser"){
						$("#img_"+typeName+"_"+context_id).attr('src','data:image/gif;base64,'+testVal);
						$("#"+typeName+"_"+context_id).val(testVal);
						$("#img_"+typeName+"_"+context_id).css('display','inline');
						$("#photo_cover_"+context_id).css('display','none');
						$("#text_cover_"+context_id).css('display','none');
						$("#delImg_"+context_id).css('display','inline');
						return false;
					}else{
					}
					/****************测试数据*****************/
				}
				
				//console.log("appVersionFlag:"+appVersionFlag);
				/*if(appVersionFlag=="Android"){//安卓版本未有解决新接口，需分离平台调用
					cordova.sino.takePhoto(callBackFun_Photo, data);//北京CA拍照接口
				}else if(appVersionFlag=="IOS"){
					cordova.sino.takePhotoOther(callBackFun_Photo, data);//信易通拍照接口
				}*/
				cordova.sino.takePhotoOther(callBackFun_Photo, data);//信易通拍照接口
			}

			var callBackFun_Photo = function(result){
				var data = result.data;
				var val = data.Base64Img;//拍照数据
				
				/***************writePhotoLog begin******************/
				var callXytParam="curentPtId="+curentPtId+",调用信易通方法：cordova.sino.takePhotoOther(callBackFun_Photo, data),参数值内容data[openFromGallery=false,imgType='OtherPhoto']";
				/*var picLogVal=val;
				if(picLogVal!=undefined && picLogVal!=null || picLogVal!=""){
					if(picLogVal.length>500){
						picLogVal=picLogVal.substring(0,500);
					}
				}*/
				var logParam={
						"opType":"photo",
						"curentPtId":callXytParam,
						"chdrnum":chdrnum01,
						"photoDataLog":data,
						"photoDataLogVal":val
				};
				$scope.writePhotoLog(logParam);
				/***************writePhotoLog end******************/
				
				if(val==undefined || val==null || val==""){
					return false;
				}
				/*var appVersionFlag = myFactory.getBrowserType();
				console.log("appVersionFlag:"+appVersionFlag);
				if(appVersionFlag=="Android"){//安卓版本未有解决新接口，需分离平台调用
					val = data.signImg;//拍照数据
				}else if(appVersionFlag=="IOS"){
					val = data.Base64Img;//拍照数据
				}*/

				if(curentPtId!=''){
					if(curentPtId=='507'){
						console.log("当前otherPtData.length:"+otherPtData.length);
						if(otherPtData.length==0){//重置动态资源变量
							otherPtAddId=0;
						}
						//var otherPtDataJson = JSON.stringify(otherPtData);
						//console.log("当前otherPtData:"+otherPtDataJson);

						//数组参数
						var keyId=otherPtAddId;
						var url='data:image/gif;base64,'+val;
						var ido=otherPtAddId;
						var idPt=val;

						var picVal={'keyId':keyId,'url': url,'ido':ido,'idPt':idPt};
						otherPtData.push(picVal);
						otherPtAddId++;
						$scope.otherPtData=otherPtData;

						/*console.log("---------------------add begin-----------------------");
						console.log("点击新增后otherPtData.length:"+otherPtData.length);
						var otherPtDataJson = JSON.stringify(otherPtData);
						console.log("点击新增后otherPtData:"+otherPtDataJson);

						var otherPtDataTemp=$scope.otherPtData;
						console.log("点击新增后otherPtDataTemp.length:"+otherPtDataTemp.length);
						var otherPtDataTempJson = JSON.stringify(otherPtDataTemp);
						console.log("点击新增后otherPtDataTemp:"+otherPtDataTempJson);
						console.log("---------------------add end-----------------------");*/
					}else{
						$("#img_"+curentPtTypeName+"_"+curentPtId).css('display','inline');
						$("#photo_cover_"+curentPtId).css('display','none');
						$("#text_cover_"+curentPtId).css('display','none');
						$("#img_"+curentPtTypeName+"_"+curentPtId).attr('src','data:image/gif;base64,'+val);
						$("#"+curentPtTypeName+"_"+curentPtId).val(val);
						$("#delImg_"+curentPtId).css('display','inline');
					}

				}
			}

			//点击删除签名图片
			$scope.deletePhoto = function(e,context_id,typeName){
				e.stopPropagation();

				$("#img_"+typeName+"_"+context_id).css('display','none');
				$("#img_"+typeName+"_"+context_id).attr('src','');
				$("#"+typeName+"_"+context_id).val("");

				$("#photo_cover_"+context_id).css('display','block');
				$("#text_cover_"+context_id).css('display','block');
				$("#delImg_"+context_id).css('display','none');
			}
			
			//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180729 begin
			$scope.deleteFacePhoto = function(e,context_id,typeName){
				e.stopPropagation();
				$("#face_img_"+typeName+"_"+context_id).css('display','none');
				$("#face_img_"+typeName+"_"+context_id).attr('src','');
				$("#"+typeName+"_"+context_id).val("");
				$("#face_photo_cover_"+context_id).css('display','block');
				$("#face_text_cover_"+context_id).css('display','block');
				$("#face_delImg_"+context_id).css('display','none');
				
				//$("#checkImg_"+context_id).attr({"src":''});
				$("#checkImg_"+context_id).css('display','none');
				if(context_id=="500"){
					verifyStatusOwFlag=false;
				}else if(context_id=="502"){
					verifyStatusLfFlag=false;
				}
			}
			//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180729 end

			//点击删除签名图片deletePhoto_otherPt
			$scope.deletePhoto_otherPt = function($event,context_id,keyId){
				//e.stopPropagation();
				if(context_id=='507'){
					$($event).parent('.create_img_wrap').remove();

					console.log("删除keyId:"+keyId);
					for(var i=0;i<otherPtData.length;i++) {
						var keyIdTemp = otherPtData[i].keyId;
						if(keyIdTemp==keyId) {
							otherPtData.splice(i,1);
						}
					}

					/*console.log("--------------------del begin------------------------");
					//console.log("点击删除后tmpData.length:"+otherPtData.length);
					var otherPtDataJson = JSON.stringify(otherPtData);
					//console.log("剩余数据otherPtData:"+otherPtDataJson);

					var otherPtDataTemp=$scope.otherPtData;
					//console.log("点击删除后otherPtDataTemp.length:"+otherPtDataTemp.length);
					var otherPtDataTempJson = JSON.stringify(otherPtDataTemp);
					//console.log("点击删除后otherPtDataTempJson:"+otherPtDataTempJson);
					console.log("--------------------del end------------------------");*/
				}

			}

			/******************页面部分显示逻辑处理end**************/
			$scope.onIdDateTypeChange = function(item1,item2){
				var options = "";
				if(item1=='holderIdDateType'){
					options =$("#holderIdDateType option:selected");
					$scope.holderCreTypeName=options.text();
				}else if(item1=='insuredIdDateType'){
					options =$("#insuredIdDateType option:selected");
					$scope.insuredCreTypeName=options.text();
				}else if(item1=='benefiIdDateType'){
					options =$("#benefiIdDateType option:selected");
					$scope.benefiCreTypeName=options.text();
				}else if (item1.indexOf('benfIdDateType_' != -1)){
					options = $("#"+ item1 +" option:selected");
					$scope.benefiIdPtData[item2].availDataTypeCN=options.text();
				}
				console.log("val:"+options.val());
				console.log("text:"+options.text());

				//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 start
				if(item1.indexOf('benfIdDateType_' != -1)){
					var idaArr = item1.split("_");
					item2 = "benfIdDate_"+idaArr[1]+"_"+idaArr[2];
				}
				//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 end
				var type =$("#"+item1).val();
				if(type=='1'){
					$("#"+item2).val("");
					$("#"+item2).attr("disabled",true);
				}else{
					$("#"+item2).removeAttr("disabled");
				}

			}
			//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
			
			//单选按钮样式控制
			$scope.choose_radio_label = function(state,flagName){
				if (state) {
					$scope.data[flagName+"Y"] = true;
					$scope.data[flagName+"N"] = false;
					console.log("selected:"+state);
				} else{
					$scope.data[flagName+"Y"] = false;
					$scope.data[flagName+"N"] = true;
					console.log("selected:"+state);
				};
			}

			//受益人单选按钮控制
			$scope.chooseBenfVerify = function(state, index) {
				$scope.benefiIdPtData[index].checkedY = state;
				$scope.benefiIdPtData[index].checkedN = !state;
			}

			//拍照倒计时3分钟
			$scope.startPhotoIterval = function(){
				maxTime=500;//100;//3*60
				timeOutPhoto="N";
				$scope.data.textFlag = false;
				$scope.data.timeRest = maxTime;
				$scope.data.timePhoto = $interval(function(){
					//console.log("timePhoto1:"+maxTime);
					//$("#ipttime").val(maxTime);
					maxTime--;
					//console.log("timePhoto2:"+maxTime);
					
					if (maxTime < 1) {
						//$scope.data.timeCon = "获取手机验证码";
						$scope.data.textFlag = true;
						$interval.cancel($scope.data.timePhoto);
					} else {
						$scope.data.timeRest = maxTime;
					}

					if(maxTime==0){
						timeOutPhoto="Y";
						$scope.data.timeRest = maxTime;
						//myFactory.alert('','拍摄超时，请返回上一步重新处理','info');
						//$("#ipttime").val(maxTime);
						//$scope.changeImg('valnumPic');//优化一下，过期不刷新，免得客户觉得又要多一次输入验证码
						//$("#valnum").val("");
						//stopIterval(timer);
						return false;
					}
				}, 1000);
			}

			
			/*根据出生日期算出年龄*/  
			function getAge(strBirthday){         
				var returnAge;  
				var strBirthdayArr=strBirthday.split("-");  
				var birthYear = strBirthdayArr[0];  
				var birthMonth = strBirthdayArr[1];  
				var birthDay = strBirthdayArr[2];  
				
				d = new Date();  
				var nowYear = d.getFullYear();  
				var nowMonth = d.getMonth() + 1;  
				var nowDay = d.getDate();  
				
				if(nowYear == birthYear){  
					returnAge = 0;//同年 则为0岁  
				} else {  
					var ageDiff = nowYear - birthYear ; //年之差  
					if(ageDiff > 0){  
						if(nowMonth == birthMonth) {  
							var dayDiff = nowDay - birthDay;//日之差  
							if(dayDiff < 0) {  
								returnAge = ageDiff - 1;  
							} else {  
								returnAge = ageDiff ;  
							}  
						} else {  
							var monthDiff = nowMonth - birthMonth;//月之差  
							if(monthDiff < 0) {  
								returnAge = ageDiff - 1;  
							} else {  
								returnAge = ageDiff ;  
							}  
						}  
					} else {  
						returnAge = -1;//返回-1 表示出生日期输入错误 晚于今天  
					}  
				}  
				return returnAge;//返回周岁年龄  
			}

			/*判断证件有效期是否正确*/
			function checkIdCardDate(birthDay, availDateStart, availDateClose) {
				var _availDateStart = availDateStart.replaceAll('-','');
				var _availDateClose = availDateClose.replaceAll('-','');
				var isPerpetual = availDateClose == '长期' || availDateClose == '终身';
				var beginMMDD = _availDateStart.substr(4, 4);
				var endMMDD = isPerpetual ? "" : _availDateClose.substr(4, 4);
				if (!isPerpetual && beginMMDD != '0229' && endMMDD != '0229' && beginMMDD != endMMDD) { //任一日期为2月29日不检测
					return false;
				}
				var realAge = getPeriod(birthDay.replaceAll('-', ''), _availDateStart);//办证年龄
				var validity = isPerpetual ? 0 : getPeriod(_availDateStart, _availDateClose);//证件年限
				if ((realAge < 16 && validity != 5)
					|| (realAge >= 16 && realAge <= 25 && validity != 10)
					|| (realAge >= 26 && realAge <= 45 && validity != 20)
					|| (realAge >= 46 && validity != 0)
				) {
					return false;
				}
				return true;
			}

			//计算年限
			function getPeriod(startDate, endDate) {
				var li_yy = 0;
				//转换日期格式暂时省略
				var startDate_yy = startDate.substr(0, 4);
				var startDate_mm = startDate.substr(4, 2);
				var startDate_dd = startDate.substr(6, 2);
				var endDate_yy = endDate.substr(0, 4);
				var endDate_mm = endDate.substr(4, 2);
				var endDate_dd = endDate.substr(6, 2);
				if (parseInt(startDate) > parseInt(endDate)) {
					return li_yy;
				}
				li_yy = endDate_yy - startDate_yy;
				if (endDate_mm < startDate_mm) {
					li_yy--;
				} else {
					if (endDate_mm == startDate_mm && endDate_dd < startDate_dd) {
						li_yy--;
					}
				}
				return li_yy;
			}
			
			//提交表单
			$scope.onsub = function () {
				myFactory.loadingShow();//显示加载圈
				if(maxTime==0){//如果超出时间限制则不能再拍照
					if(timeOutPhoto=="Y"){
						myFactory.alert('','拍摄超时，请返回上一步重新处理','info');
						myFactory.loadingHide();
					}
					return false;
				}

				var photoCheck=submitCheck();
				console.log("photoCheck:"+photoCheck);
				if(!photoCheck){
					console.log("拍照校验不通过");
					myFactory.loadingHide();
					return false;
				}
				console.log("拍照校验通过");
				$interval.cancel($scope.data.timePhoto);//立即终止倒计时,避免出现滚动条转动的时候已经到时间临界点

				
			    var idtype_t = $("#idtype_t").val(); //投保人证件类型（注意是中文名字）
			    var idtype_b = $("#idtype_b").val(); //被保人证件类型（注意是中文名字）
			    var secuityno_t = $("#secuityno_t").val();//投保人证件号码
			    var rnIdNumber_b = $("#rnIdNumber_b").val();//被把人证件号码
			    //S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 upate by huanghk 20231115 start
				if(idtype_t=='外国人永久居留身份证' && $("#holderIdDateType").val()==1){
					/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 start*/
					myFactory.alert("","投保人的证件类型为'外国人永久居留身份证',有效期类型不可选择长期","info");
					/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 end*/
					myFactory.loadingHide();
					return false;
				}
				if(idtype_b=='外国人永久居留身份证' && $("#insuredIdDateType").val()==1){
					/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 start*/
					myFactory.alert("","被保险人的证件类型为'外国人永久居留身份证',有效期类型不可选择长期","info");
					/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 end*/
					myFactory.loadingHide();
					return false;
				}
				//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 upate by huanghk 20231115 end
				
				//证件类型为身份证时，45岁（含）以下证件有效期不可为终身   BY ZZQ 2017-10-21
				if(idtype_t=='身份证' && $("#holderIdDateType").val()==1){
					var iDate = secuityno_t.length == 18 ? secuityno_t.substr(6, 8) : ""//出生日期
					if (iDate != "") {
				  		var tempdate = iDate.substr(0,4) + "-" + iDate.substr(4,2) + "-" + iDate.substr(6,2);
						var age = getAge(tempdate);
						if (age <= 45) {
							/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 start*/
							myFactory.alert("","45岁（含）以下有效期类型不可为长期，请重新确认!","info");
							/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 end*/
							myFactory.loadingHide();
							return false;
						}
				  	}
				}
				if(idtype_b=='身份证' && $("#insuredIdDateType").val()==1){
					var iDate = rnIdNumber_b.length == 18 ? rnIdNumber_b.substr(6, 8) : ""//出生日期
					if (iDate != "") {
				  		var tempdate = iDate.substr(0,4) + "-" + iDate.substr(4,2) + "-" + iDate.substr(6,2);
						var age = getAge(tempdate);
						if (age <= 45) {
							myFactory.alert("","45岁（含）以下有效期类型不可为终身，请重新确认!","info");
							myFactory.loadingHide();
							return false;
						}
				  	}
				}
				
				var isVerify_a_Y=$scope.data.holderY;
				var isVerify_a_N=$scope.data.holderN;

				//投/被保人
				if(photoRule.policyHolderID=='Y'){
					if(false==isVerify_a_Y && false==isVerify_a_N){
						myFactory.alert('','请核对投保人证件号码是否一致！','info');
						myFactory.loadingHide();
						return false;
					}else{
						var isSamePerson_a = document.getElementById("isSamePerson_a").value;
						//var a = isVerify_a.value;
						var str = "";
						if("Y"==isSamePerson_a){
							//str = "投/被保险人";
							str = "投保人";
						}else{
							str = "投保人";
						}
						if(true==isVerify_a_N){
							myFactory.alert('',str+'证件发生变化（或证件号码变更后与证件原件号码不一致），请客户同时办理客户身份信息变更！','info');
							myFactory.loadingHide();
							return false;
						}
					}
				}
				
				var isVerify_b_Y=$scope.data.insuredY;
				var isVerify_b_N=$scope.data.insuredN;
				//被保人
				//if(1==1){
				if(photoRule.insuredID=='Y'){
					if(checkFlag10=="N"){
						if(false==isVerify_b_Y && false==isVerify_b_N){
							myFactory.alert('','请核对被保险人证件号码是否一致！','info');
							myFactory.loadingHide();
							return false;
						}else{
							if(true==isVerify_b_N){
								myFactory.alert('','被保险人证件发生变化（或证件号码变更后与证件原件号码不一致），请客户同时办理客户身份信息变更！','info');
								myFactory.loadingHide();
								return false;
							}
						}
					}else{
						var flag = sessionStorage.getItem("isChange_insured_item10");
						//移动保全1.0规则，如只变更投保人信息，则只需要投保人签名及身份证件留影，投保人与被保险人同时核对身份信息是否一致。
						//当变更被保险人或同时变更投保人与被保险人，则才同时需要投保人与被保险人同时签名及身份证件留影。
						//如果被保人信息没有被更改
						//判断投保人被保人是否同一个人，是的话，即使更新了10变更项，也仍然不需要被保人签名 add by csf start
						if(1==flag && !isSamePerson){
						//判断投保人被保人是否同一个人，是的话，即使更新了10变更项，也仍然不需要被保人签名 add by csf end
							if(false==isVerify_b_Y && false==isVerify_b_N){
								myFactory.alert('','请核对被保险人证件号码是否一致！','info');
								myFactory.loadingHide();
								return false;
							}else{
								if(true==isVerify_b_N){
									myFactory.alert('','被保险人证件发生变化（或证件号码变更后与证件原件号码不一致），请客户同时办理客户身份信息变更！','info');
									myFactory.loadingHide();
									return false;
								}
							}
						}
					}
				}

				var frm_photo="img/gotoFinish.action";

				//证件有效期类型和证件有效期
				var holderIdDateType = $("#holderIdDateType").val();
				//var holderIdDateType = $("#holderIdDateType option:selected").val();
				var holderIdDate = $("#holderIdDate").val();
		 	    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
                var holderIdDateStart = $("#holderIdDateStart").val();
                var insuredIdDateStart = $("#insuredIdDateStart").val();
                var benefiIdDateStart = $("#benefiIdDateStart").val();
		 	    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				var insuredIdDateType = $("#insuredIdDateType").val();
				//var insuredIdDateType = $("#insuredIdDateType option:selected").val();
				var insuredIdDate = $("#insuredIdDate").val();
				var benefiIdDateType = $("#benefiIdDateType").val();
				//var benefiIdDateType = $("#benefiIdDateType option:selected").val();
				var benefiIdDate = $("#benefiIdDate").val();

				if(holderIdDateType==undefined || holderIdDateType.indexOf("undefined")>=0){
					holderIdDateType="";
				}
				if(holderIdDate==undefined){
					holderIdDate="";
				}
		 	    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
				if(holderIdDateStart==undefined){
					holderIdDateStart="";
				}
		 	    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				if(insuredIdDateType==undefined || insuredIdDateType.indexOf("undefined")>=0){
					insuredIdDateType="";
				}
				if(insuredIdDate==undefined){
					insuredIdDate="";
				}
		 	    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
				if(insuredIdDateStart==undefined){
					insuredIdDateStart="";
				}
		 	    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				if(benefiIdDateType==undefined || benefiIdDateType.indexOf("undefined")>=0){//? undefined:undefined ? str.indexOf(substr) >= 0
					benefiIdDateType="";
				}
				if(benefiIdDate==undefined){
					benefiIdDate="";
				}
				//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
				if(benefiIdDateStart==undefined){
					benefiIdDateStart="";
				}
				
				//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 upate by huanghk 20231115 start
				if(idtype_t=='外国人永久居留身份证'){
					if(holderIdDateStart!="" && holderIdDate!=""){
						var birthday = policy.cltdob +"";
						if(photoMainData.ow_birthday!=""){
							birthday = photoMainData.ow_birthday;
						}
						console.log("holderIdDateStart="+holderIdDateStart);
						console.log("holderIdDate="+holderIdDate);
						console.log("birthday="+birthday);
						if(!changeAvailDataStart(holderIdDateStart,holderIdDate,birthday)){
							myFactory.alert("","您填写的投保人证件有效期不正确，请按证件上的实际有效日期填写！","info");
							myFactory.loadingHide();
							return false;
						}
					}
				}
								
				if(idtype_b=='外国人永久居留身份证'){
					if(insuredIdDateStart!="" && insuredIdDate!=""){
						var birthday = policy.rnBirthday +"";
						if(photoMainData.lf_birthday!=""){
							birthday = photoMainData.lf_birthday;
						}
						console.log("insuredIdDateStart="+insuredIdDateStart);
						console.log("insuredIdDate="+insuredIdDate);
						console.log("birthday="+birthday);
						if(!changeAvailDataStart(insuredIdDateStart,insuredIdDate,birthday)){
							myFactory.alert("","您填写的被保险人证件有效期不正确，请按证件上的实际有效日期填写！","info");
							myFactory.loadingHide();
							return false;
						}
					}
				}
				//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 upate by huanghk 20231115 end


		 	    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				var policyHolderPt = [];//投保人留影数据
				var policyHolderIdPt = [];//投保人身份证明数据
				var insuredPt = [];//被保人留影数据
				var insuredIdPt = [];//被保人身份证明数据
				var benefiPt = [];//受益人留影数据
				var benefiIdPt = [];//受益人身份证明数据
				var bankPt = [];//银行存折/卡留影数据
				var otherPt = [];//其他随附资料留影数据

				var policyHolderPt_500=$("#policyHolderPt_500").val();
				if(policyHolderPt_500!='' && policyHolderPt_500!=undefined){
					policyHolderPt.push(policyHolderPt_500);
				}

				var policyHolderIdPt_501a=$("#policyHolderIdPt_501a").val();
				var policyHolderIdPt_501b=$("#policyHolderIdPt_501b").val();
				// 修复投保人/被保人/受益人身份证明文件当只选择一个的时候，会导致受益人身份证明文件无法上传、丢失 add by csf 20181210 start
				if((policyHolderIdPt_501a!='' && policyHolderIdPt_501a!=undefined )||( policyHolderIdPt_501b!='' && policyHolderIdPt_501b!=undefined)){
				// 修复投保人/被保人/受益人身份证明文件当只选择一个的时候，会导致受益人身份证明文件无法上传、丢失 add by csf 20181210 end
//				if(policyHolderIdPt_501a!='' && policyHolderIdPt_501a!=undefined && policyHolderIdPt_501b!='' && policyHolderIdPt_501b!=undefined){
					policyHolderIdPt.push(policyHolderIdPt_501a);
					policyHolderIdPt.push(policyHolderIdPt_501b);
				}

				var insuredPt_502=$("#insuredPt_502").val();
				if(insuredPt_502!='' && insuredPt_502!=undefined){
					insuredPt.push(insuredPt_502);
				}

				var insuredIdPt_503a=$("#insuredIdPt_503a").val();
				var insuredIdPt_503b=$("#insuredIdPt_503b").val();
				 //关于被保人身份证明文件相关信息丢失的问题处理 add by csf 20181206 start
				//if(insuredIdPt_503a!='' && insuredIdPt_503a!=undefined && insuredIdPt_503b!='' && insuredIdPt_503b!=undefined){
				if((insuredIdPt_503a!='' && insuredIdPt_503a!=undefined) ||( insuredIdPt_503b!='' && insuredIdPt_503b!=undefined)){
				//关于被保人身份证明文件相关信息丢失的问题处理 add by csf 20181206 end
					insuredIdPt.push(insuredIdPt_503a);
					insuredIdPt.push(insuredIdPt_503b);
				}

				var benefiPt_504=$("#benefiPt_504").val();
				if(benefiPt_504!='' && benefiPt_504!=undefined){
					benefiPt.push(benefiPt_504);
				}

				var benefiIdPt_504a=$("#benefiIdPt_504a").val();
				var benefiIdPt_504b=$("#benefiIdPt_504b").val();
//				if(benefiIdPt_504a!='' && benefiIdPt_504a!=undefined && benefiIdPt_504b!='' && benefiIdPt_504b!=undefined){
				// 修复投保人/被保人/受益人身份证明文件当只选择一个的时候，会导致受益人身份证明文件无法上传、丢失 add by csf 20181210 start
				if((benefiIdPt_504a!='' && benefiIdPt_504a!=undefined)||(  benefiIdPt_504b!='' && benefiIdPt_504b!=undefined)){
					// 修复投保人/被保人/受益人身份证明文件当只选择一个的时候，会导致受益人身份证明文件无法上传、丢失 add by csf 20181210 end
					benefiIdPt.push(benefiIdPt_504a);
					benefiIdPt.push(benefiIdPt_504b);
				}

				var benefiIdPtDataCheck=$scope.benefiIdPtData;
				var benefitList = photoMainData.benefitList;
				if(benefiIdPtDataCheck.length>0){
					for(var i=0;i<benefiIdPtDataCheck.length;i++) {
						//增加证件有效期校验 add by lb 20220930 start
						if (!benefiIdPtDataCheck[i].checkedY && !benefiIdPtDataCheck[i].checkedN) {
							myFactory.alert('','请核对受益人['+ benefiIdPtDataCheck[i].name + ']证件号码是否一致！','info');
							myFactory.loadingHide();
							return false;
						}
						if (benefiIdPtDataCheck[i].checkedN) {
							myFactory.alert('','受益人['+ benefiIdPtDataCheck[i].name +']证件发生变化（或证件号码变更后与证件原件号码不一致），请确认！','info');
							myFactory.loadingHide();
							return false;
						}
						
						//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 start
						var availDataType = benefiIdPtDataCheck[i].availDataType;
						var availDataStart = benefiIdPtDataCheck[i].availDataStart;
						var availDataClose = benefiIdPtDataCheck[i].availDataClose;
						//有效期起始日校验
						if(availDataStart==""||availDataStart==undefined||availDataStart==null){
							myFactory.alert('','受益人['+ benefiIdPtDataCheck[i].name +']证件有效期起始日不能为空!','info');
							myFactory.loadingHide();
							return false;
						}
						if(compareDate(getDate(availDataStart),getDate(sysDate))){
							myFactory.alert('','受益人['+ benefiIdPtDataCheck[i].name +']证件有效期起始日必须小于等于当前日!','info');
							myFactory.loadingHide();
							return false;
						}
						if(compareDate(getDate(benefitList[i].birthDay),getDate(availDataStart))){
							myFactory.alert('','受益人['+ benefiIdPtDataCheck[i].name +']证件有效期起始日必须小于等于出生日期!','info');
							myFactory.loadingHide();
							return false;
						}
						//有效期截止日校验
						if(availDataType=='2' && (availDataClose==""||availDataClose==undefined||availDataClose==null)){
							myFactory.alert('','受益人['+ benefiIdPtDataCheck[i].name +']证件有效期截止日不能为空!','info');
							myFactory.loadingHide();
							return false;
						}
						var availDataCloseStr = "";
						if(availDataClose.indexOf("-")> -1){
							availDataCloseStr = availDataClose.substring(0,4)+availDataClose.substring(5,7)+availDataClose.substring(8,10);
						}
						//调用getDate，参数没有“-”会有问题
						if(availDataType=='2' && !compareDate(getDate(availDataClose),getDate(sysDate))){
							myFactory.alert('','受益人['+ benefiIdPtDataCheck[i].name +']证件有效期截止日应该大于当前日期!','info');
							myFactory.loadingHide();
							return false;
						}
						//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 end
						//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 update by huanghk 20231116 start
						if(benefitList[i].idType=="A"){
							if(availDataType=='1'){
								var errormsg = "受益人["+ benefiIdPtDataCheck[i].name +"]的证件类型为'外国人永久居留身份证',有效期类型不可选择长期";
								myFactory.alert("",errormsg,"info");
								myFactory.loadingHide();
								return false;
							}
							if(!changeAvailDataStart(availDataStart,availDataClose,benefitList[i].birthDay)){
								myFactory.alert("",'您填写的受益人['+ benefiIdPtDataCheck[i].name +']证件有效期不正确，请按证件上的实际有效日期填写！',"info");
								myFactory.loadingHide();
								return false;
							}
						}
						//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 update by huanghk 20231116 end						
						benefitList[i].availDataType = benefiIdPtDataCheck[i].availDataType;
						benefitList[i].availDataStart = benefiIdPtDataCheck[i].availDataStart;
						benefitList[i].availDataClose = benefiIdPtDataCheck[i].availDataClose;
						//增加证件有效期校验 add by lb 20220930 end
						var ida = benefiIdPtDataCheck[i].ida;
						var idb = benefiIdPtDataCheck[i].idb;
						if($("#benefiIdPt_"+ida).val() && $("#benefiIdPt_"+idb).val()){
							benefiIdPt.push($("#benefiIdPt_"+ida).val());
							benefiIdPt.push($("#benefiIdPt_"+idb).val());
						}
					}
				}

				var bankPt_506a=$("#bankPt_506a").val();
				//var bankPt_506b=$("#bankPt_506b").val();
				if(bankPt_506a!='' && bankPt_506a!=undefined){//&& bankPt_506b!='' && bankPt_506b!=undefined
					bankPt.push(bankPt_506a);
					//bankPt.push(bankPt_506b);
				}

				var otherPtDataCheck=$scope.otherPtData;
				for(var i=0;i<otherPtDataCheck.length;i++) {
					var ido = otherPtDataCheck[i].ido;
					var idPt_507="";
					if($("#idPt_"+ido).val()){
						idPt_507=$("#idPt_"+ido).val();
						otherPt.push(idPt_507);
					}
				}

				//传递参数，注意Tomcat要设一个max类型的值，因为数据量太大,否则报错
				var params={
					"holderIdDateType":holderIdDateType,
			 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
                    "holderIdDateStart":holderIdDateStart,
                    "insuredIdDateStart":insuredIdDateStart,
					"benefiIdDateStart":benefiIdDateStart,
			 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
					"holderIdDate":holderIdDate,
					"insuredIdDateType":insuredIdDateType,
					"insuredIdDate":insuredIdDate,
					"benefiIdDateType":benefiIdDateType,
					"benefiIdDate":benefiIdDate,

					"policyHolderPt":policyHolderPt,
					"policyHolderIdPt":policyHolderIdPt,
					"insuredPt":insuredPt,
					"insuredIdPt":insuredIdPt,
					"benefiPt":benefiPt,
					"benefiIdPt":benefiIdPt,
					"bankPt":bankPt,
					"otherPt":otherPt
				};

				var photoItems={"photoItems":params};
				//var otherPtTest=otherPt;
				//$timeout(function(){myFactory.loadingHide();},2000); 2秒这里并不足够，采用等待服务器响应比较好
				var token=sessionStorage.getItem("token");
				var timestamp=myFactory.getTimetamp();
				var sfis= "token-timestamp";
				var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				$http({
					method: 'post',
					url: app.domain + frm_photo,
					data:{paramsMap:photoItems,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						var validateMsg = response.data.data.validateMsg;
						if(validateMsg!=""){
							myFactory.alert('',validateMsg,'info');
							myFactory.loadingHide();
							return false;
						}else{
							var redirectAction = response.data.data.redirectAction;
							if(redirectAction!=undefined && redirectAction!=null && redirectAction!=""){
								//结案授权凭证id-一次使用后失效
								//tokenEndAuthorId=response.data.data.tokenEndAuthorId;
								
								//初始化放到end_main再做 BY ZZQ 2017-9-7 
								$interval.cancel($scope.data.timePhoto);//立即终止倒计时
								myFactory.loadingHide();
								$ionicHistory.clearCache().then(function(){
									$state.go('end_main',{
										itemId:itemId,
										chdrnum01:chdrnum01,
										chdrcoy:chdrcoy,
									    photoMainData:photoMainData,
										signMainData:signMainData,
										tokenEndAuthorId:tokenEndAuthorId
									});
								});
								
//								$http({
//									method: 'GET',
//									url: app.domain + redirectAction
//								}).then(function successCallback(response) {
//									var endData = response.data.data.endData;
//									var itemCommonList = response.data.data.endData.itemCommonList;
//									var policy = response.data.data.policy;
//									var strItemIds = response.data.data.strItemIds;
//
//									$interval.cancel($scope.data.timePhoto);//立即终止倒计时
//									myFactory.loadingHide();
//									$state.go('end_main',{
//										itemId:itemId,
//										chdrnum01:chdrnum01,
//										chdrcoy:chdrcoy,
//										itemCommonList:itemCommonList,
//										strItemIds:strItemIds,
//										endData:endData,
//										policy:policy,
//										photoMainData:photoMainData,
//										signMainData:signMainData
//									});
//								}, function errorCallback(response) {
//									myFactory.loadingHide();
//									myFactory.alert('','访问后台失败4，请返回重试','info');
//								});
							}else{
								myFactory.loadingHide();
								$interval.cancel($scope.data.timePhoto);//立即终止倒计时
								myFactory.alert('','系统查询出错，请返回重试','info');
							}
						}
					}else{
						myFactory.loadingHide();
						$interval.cancel($scope.data.timePhoto);//立即终止倒计时
						myFactory.alert('','系统没有响应，请返回重试','info');
					}
				}, function errorCallback(response) {
					myFactory.loadingHide();
					$interval.cancel($scope.data.timePhoto);//立即终止倒计时
					//myFactory.alert('','访问后台失败，请返回重试！','info');
				});
			}

			function submitCheck(){
				var holderIdDate = $("#holderIdDate");
		 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
				var holderIdDateStart = $("#holderIdDateStart");
				var insuredIdDateStart = $("#insuredIdDateStart");
				var benefiIdDateStart = $("#benefiIdDateStart");
		 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				var insuredIdDate = $("#insuredIdDate");
				var benefiIdDate = $("#benefiIdDate");
				var holderIdDateType = $("#holderIdDateType");
				var insuredIdDateType = $("#insuredIdDateType");
				var benefiIdDateType = $("#benefiIdDateType");

				var checkFlag10=checkIsItemIdType("10");

				//投/被保人
				if(photoRule.policyHolderID=='Y'){
					//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 start
					var type =holderIdDateType.val();
					if(type=='1' && photoMainData.ow_idTypeName == "外国人永久居留身份证"){
						/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 start*/
						//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 update by huanghk 20231116 start
						myFactory.alert("","投保人的证件类型为'外国人永久居留身份证',有效期类型不可选择长期","info");
						//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 update by huanghk 20231116 end
						/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 end*/
						return;
					}
					if(type=='2' && !holderIdDate.val()){
						myFactory.alert('','投保人证件有效期不能为空!','info');
						return false;
					}
					//如果证件日期小于当前日期则不允许通过
					
					var hIdDate = holderIdDate.val();
					if(holderIdDate.val().indexOf("-")> -1){
						hIdDate = holderIdDate.val().substring(0,4)+holderIdDate.val().substring(5,7)+holderIdDate.val().substring(8,10);
					}
					console.log(hIdDate);
					if(type=='2' && !compareDate(getDate(holderIdDate.val()),getDate(sysDate))
							&& !(photoMainData.ow_idTypeName=="港澳回乡证" && !compareDate(getDate(sysDate),getDate("2023-12-31")) && hIdDate>=20200101 && hIdDate<=20231230)){
						myFactory.alert('','投保人证件有效期截止日应该大于当前日期!','info');
						return false;
					}
			 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
					
					if(type=='2' && !holderIdDateStart.val()){
						myFactory.alert('','投保人证件有效期起始日不能为空!','info');
						return false;
					}
					
					if(type=='2' && compareDate(getDate(holderIdDateStart.val()),getDate(sysDate))){
						myFactory.alert('','投保人证件有效期起始日必须少于等于当前日!','info');
						return false;
					}
					if(type=='2' && !compareDate(getDate(holderIdDateStart.val()),getDate('20040329'))){
						myFactory.alert('','投保人证件有效期起始日必须大于等于2004年3月29日（二代身份证启用日）!','info');
						return false;
					}
					
			 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
					//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 end
				}

				//被保人
				if(photoRule.insuredID=='Y'){
					//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 start
					if(checkFlag10=="N"){
						var type = insuredIdDateType.val();
						if(type=='1' && photoMainData.lf_idTypeName == "外国人永久居留身份证"){
							/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 start*/
							//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 update by huanghk 20231116 start
							myFactory.alert("","被保险人的证件类型为'外国人永久居留身份证',有效期类型不可选择长期","info");
							//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 update by huanghk 20231116 end
							/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 end*/
							return;
						}
						if(type=='2' && !insuredIdDate.val()){
							myFactory.alert('','被保险人证件有效期不能为空!','info');
							return false;
						}
						//如果证件日期小于当前日期则不允许通过
						
						var iIdDate = insuredIdDate.val();
						if(insuredIdDate.val().indexOf("-")> -1){
							iIdDate = insuredIdDate.val().substring(0,4)+insuredIdDate.val().substring(5,7)+insuredIdDate.val().substring(8,10);
						}
						console.log(iIdDate);
						if(type=='2' && !compareDate(getDate(insuredIdDate.val()),getDate(sysDate)) 
								&& !(photoMainData.lf_idTypeName=="港澳回乡证" && !compareDate(getDate(sysDate),getDate("2023-12-31")) && iIdDate>=20200101 && iIdDate<=20231230)){
							myFactory.alert('','被保险人证件有效期截止日应该大于当前日期!','info');
							return false;
						}
						 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
						
						if(type=='2' && !insuredIdDateStart.val()){
							myFactory.alert('','被保险人证件有效期起始日不能为空!','info');
							return false;
						}
						
						if(type=='2' && compareDate(getDate(insuredIdDateStart.val()),getDate(sysDate))){
							myFactory.alert('','被保险人证件有效期起始日必须少于等于当前日!','info');
							return false;
						}
						if(type=='2' && !compareDate(getDate(insuredIdDateStart.val()),getDate('20040329'))){
							myFactory.alert('','被保险人证件有效期起始日必须大于等于2004年3月29日（二代身份证启用日）!','info');
							return false;
						}
						
				 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
					}else{
						var flag = sessionStorage.getItem("isChange_insured_item10");
						//移动保全1.0规则，如只变更投保人信息，则只需要投保人签名及身份证件留影，投保人与被保险人同时核对身份信息是否一致。
						//当变更被保险人或同时变更投保人与被保险人，则才同时需要投保人与被保险人同时签名及身份证件留影。
						//如果被保人信息没有被更改
						if(1==flag){
							var type = insuredIdDateType.val();
							if(type=='1' && photoMainData.lf_idTypeName == "外国人永久居留身份证"){
								/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 start*/
								//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 update by huanghk 20231116 start
								myFactory.alert("","被保险人的证件类型为'外国人永久居留身份证',有效期类型不可选择长期","info");
								//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 update by huanghk 20231116 end
								/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 end*/
								return;
							}
							if(type=='2' && !insuredIdDate.val()){
								myFactory.alert('','被保险人证件有效期不能为空!','info');
								return false;
							}
							//如果证件日期小于当前日期则不允许通过
							//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 start
							var iIdDate = insuredIdDate.val();
							if(insuredIdDate.val().indexOf("-")> -1){
								iIdDate = insuredIdDate.val().substring(0,4)+insuredIdDate.val().substring(5,7)+insuredIdDate.val().substring(8,10);
							}
							console.log(iIdDate);
							if(type=='2' && !compareDate(getDate(insuredIdDate.val()),getDate(sysDate)) 
									&& !(photoMainData.lf_idTypeName=="港澳回乡证" && !compareDate(getDate(sysDate),getDate("2023-12-31")) && iIdDate>=20200101 && iIdDate<=20231230)){
								myFactory.alert('','被保险人证件有效期截止日应该大于当前日期!','info');
								return false;
							}
							//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 end
							 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
							
							if(type=='2' && !insuredIdDateStart.val()){
								myFactory.alert('','被保险人证件有效期起始日不能为空!','info');
								return false;
							}
							
							if(type=='2' && compareDate(getDate(insuredIdDateStart.val()),getDate(sysDate))){
								myFactory.alert('','被保险人证件有效期起始日必须少于等于当前日!','info');
								return false;
							}
							if(type=='2' && !compareDate(getDate(insuredIdDateStart.val()),getDate('20040329'))){
								myFactory.alert('','被保险人证件有效期起始日必须大于等于2004年3月29日（二代身份证启用日）!','info');
								return false;
							}
							
					 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
						}
					}
					//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 end
				}

				//权益人
				//if(1==1){
				if(photoRule.benefiID=='Y'&& photoMainData.showBenefiIdDate!='N'){
					//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 start
					var type = benefiIdDateType.val();
					if(type=='2' && !benefiIdDate.val()){
						myFactory.alert('','权益人证件有效期不能为空!','info');
						return false;
					}
					//如果证件日期小于当前日期则不允许通过
					
					var bIdDate = benefiIdDate.val();
					if(benefiIdDate.val().indexOf("-")> -1){
						bIdDate = benefiIdDate.val().substring(0,4)+benefiIdDate.val().substring(5,7)+benefiIdDate.val().substring(8,10);
					}
					console.log(bIdDate);
					if(type=='2' && !compareDate(getDate(benefiIdDate.val()),getDate(sysDate))
							&& !(photoMainData.bn_idTypeName=="港澳回乡证" && bIdDate>=20200101 && bIdDate<=20231230)){
						myFactory.alert('','权益人证件有效期截止日应该大于当前日期!','info');
						return false;
					}
					//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 end
				 }

				//全部拍照数据统一校验
				/*var policyHolderPt=$("#imgshow_policyHolderPt");
				var policyHolderIdPt=$("#imgshow_policyHolderIdPt");
				var insuredPt=$("#imgshow_insuredPt");
				var insuredIdPt=$("#imgshow_insuredIdPt");
				var benefiPt=$("#imgshow_benefiPt");
				var benefiIdPt=$("#imgshow_benefiIdPt");
				var bankPt=$("#imgshow_bankPt");
				var otherPt=$("#imgshow_otherPt");*/

				//投/被保人 投/被保人证件
				if(photoRule.policyHolder=='Y'){
					//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
//					if(photoMainData.ow_idTypeName=="身份证" && "Y"==isNewHighRefundFeeFlag){
					// S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 start
					if("Y"==isNewHighRefundFeeFlag || stallShow){
					// S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 end	
						if(!verifyStatusOwFlag){
							myFactory.alert('','人脸识别不通过','info');
							return false;
						}
					} else {
						if(!$("#policyHolderPt_500").val()){
							myFactory.alert('','留影不能为空!','info');
							return false;
						}
					}
					
					//身份证，获取扫描证件信息
					/*if(){//从扫描中获取证件，还有确定证件类型为
						
					}
					myFactory.alert('','投保人证件发生变化（或证件号码变更后与证件原件号码不一致），请客户同时办理客户身份信息变更！','info');
					myFactory.loadingHide();*/
					
					//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
				}

				if (photoRule.policyHolderID=='Y'){
					if (photoMainData.ow_idTypeName=="身份证" ){
						if(!$("#policyHolderIdPt_501a").val() || !$("#policyHolderIdPt_501b").val()){
							myFactory.alert('','投保人身份证明留影不能为空!','info');
							return false;
						}
					} else {
						if(!$("#policyHolderIdPt_501a").val() && !$("#policyHolderIdPt_501b").val()){
							myFactory.alert('','投保人身份证明留影不能为空!','info');
							return false;
						}
					}
				}
				//修复投保人/被保人/受益人身份证明文件当只选择一个的时候，会导致受益人身份证明文件无法上传、丢失、拦截提示的问题  add by csf 20181210 end
				//被保人 投/被保人证件
				if(photoRule.insured=='Y'){
					//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
					if(checkFlag10=="N"){
						if( "Y"==isNewHighRefundFeeFlag || stallShow){
							if(!verifyStatusLfFlag){
								myFactory.alert('','人脸识别不通过','info');
								return false;
							}
						}else{
							if(!$("#insuredPt_502").val()){
								myFactory.alert('','被保险人留影不能为空!','info');
								return false;
							}
						}
					}else{
						var flag = sessionStorage.getItem("isChange_insured_item10");
						//移动保全1.0规则，如只变更投保人信息，则只需要投保人签名及身份证件留影，投保人与被保险人同时核对身份信息是否一致。
						//当变更被保险人或同时变更投保人与被保险人，则才同时需要投保人与被保险人同时签名及身份证件留影。
						//如果被保人信息没有被更改
						if(1==flag){
							if( "Y"==isNewHighRefundFeeFlag || stallShow){
								if(!verifyStatusLfFlag){
									myFactory.alert('','人脸识别不通过!','info');
									return false;
								}
							}else{
								if(!$("#insuredPt_502").val()){
									myFactory.alert('','被保险人留影不能为空!','info');
									return false;
								}
							}
						}
					}
					//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
				}

				//if(1==1){
				if(photoRule.insuredID=='Y'){
					//if($("input[name='insuredIdPt']").length<1){
					if(checkFlag10=="N"){
						//修复投保人/被保人/受益人身份证明文件当只选择一个的时候，会导致受益人身份证明文件无法上传、丢失、拦截提示的问题  add by csf 20181210 start
						if(photoMainData.lf_idTypeName=="身份证"){
							if(!$("#insuredIdPt_503a").val() || !$("#insuredIdPt_503b").val()){
								myFactory.alert('','被保险人身份证明留影不能为空!','info');
								return false;
							}
						}else {
							if(!$("#insuredIdPt_503a").val() && !$("#insuredIdPt_503b").val()){
								myFactory.alert('','被保险人身份证明留影不能为空!','info');
								return false;
							}
						}
						//修复投保人/被保人/受益人身份证明文件当只选择一个的时候，会导致受益人身份证明文件无法上传、丢失、拦截提示的问题  add by csf 20181210 end
					}else{
						var flag = sessionStorage.getItem("isChange_insured_item10");
						//移动保全1.0规则，如只变更投保人信息，则只需要投保人签名及身份证件留影，投保人与被保险人同时核对身份信息是否一致。
						//当变更被保险人或同时变更投保人与被保险人，则才同时需要投保人与被保险人同时签名及身份证件留影。
						if(flag==1){
							//修复投保人/被保人/受益人身份证明文件当只选择一个的时候，会导致受益人身份证明文件无法上传、丢失、拦截提示的问题  add by csf 20181210 start
							if(photoMainData.lf_idTypeName=="身份证"){
								if(!$("#insuredIdPt_503a").val() || !$("#insuredIdPt_503b").val()){
									myFactory.alert('','被保险人身份证明留影不能为空!','info');
									return false;
								}
							}else {
								if(!$("#insuredIdPt_503a").val() && !$("#insuredIdPt_503b").val()){
									myFactory.alert('','被保险人身份证明留影不能为空!','info');
									return false;
								}
							}
							//修复投保人/被保人/受益人身份证明文件当只选择一个的时候，会导致受益人身份证明文件无法上传、丢失、拦截提示的问题  add by csf 20181210 end
						}
					}
				}

				//权益人
				if(photoRule.benefi=='Y'){
					var checkFlag08=checkIsItemIdType("08");
					if(checkFlag08=="N"){
						if(!$("#benefiPt_504").val()){
							myFactory.alert('','权益人留影不能为空!','info');
							return false;
						}
					}
				}

				//if(1==1){
				if(photoRule.benefiID=='Y'){//&& photoMainData.showBenefiIdDate!='N'
					var resultRes=checkIsBenefiItemIdType();
					if(resultRes=="N"){
						if(!$("#benefiIdPt_504a").val() || !$("#benefiIdPt_504b").val()){
							myFactory.alert('','权益人身份证明留影不能为空!','info');
							return false;
						}
					}else if(resultRes=="Y_08_S"){
						var checkFlag=true;
						var benefiIdPtDataCheck=$scope.benefiIdPtData;
						for(var i=0;i<benefiIdPtDataCheck.length;i++) {
							var ida = benefiIdPtDataCheck[i].ida;
							var idb = benefiIdPtDataCheck[i].idb;
							//if(!($("#benefiIdPt_"+ida).val()!='' && $("#benefiIdPt_"+idb).val()!='')){
							if(!$("#benefiIdPt_"+ida).val() || !$("#benefiIdPt_"+idb).val()){
								myFactory.alert('','受益人身份证明留影不能为空!','info');
								checkFlag=false;
								break;
							}
						}
						//console.log("testlen:"+$("input[name='benefiIdPt']").length);
						//if($("input[name='benefiIdPt']").length<1){
						if(!checkFlag){
							myFactory.alert('','受益人身份证明留影不能为空!','info');
							return false;
						}
					}else if(resultRes=="Y_08_B"){
						if(!$("#benefiIdPt_504a").val() || !$("#benefiIdPt_504b").val()){
							myFactory.alert('','权益人身份证明留影不能为空!','info');
							return false;
						}
					}else if(resultRes=="Y_08_D"){
						if(!$("#benefiIdPt_504a").val() || !$("#benefiIdPt_504b").val()){
							myFactory.alert('','权益人身份证明留影不能为空!','info');
							return false;
						}

						var checkFlag=true;
						var benefiIdPtDataCheck=$scope.benefiIdPtData;
						for(var i=0;i<benefiIdPtDataCheck.length;i++) {
							var ida = benefiIdPtDataCheck[i].ida;
							var idb = benefiIdPtDataCheck[i].idb;
							if(!$("#benefiIdPt_"+ida).val() || !$("#benefiIdPt_"+idb).val()){
								myFactory.alert('','受益人身份证明留影不能为空!','info');
								checkFlag=false;
								break;
							}
						}
						if(!checkFlag){
							myFactory.alert('','受益人身份证明留影不能为空!','info');
							return false;
						}
					}
				}

				//银行卡
				if(photoRule.bank=='Y'){
					//if($("input[name='bankPt']").length<1){
					/*if(!$("#bankPt_506a").val() || !$("#bankPt_506b").val()){
						myFactory.alert('','银行存折/卡留影不能为空!','info');
						return false;
					}*/
					if(!$("#bankPt_506a").val()){
						myFactory.alert('','银行存折/卡留影不能为空!','info');
						return false;
					}
				}

				//S2018122906735移动保全新增变更项目及功能的优化需求 add by mqz 20200901 start
				if(photoRule.other=='Y'){
					if ("" != strItemIds) {
						var itemIdTypeTemp="";
						var strItemIdsSplit = strItemIds.split(",");
						for(var k=0;k<strItemIdsSplit.length;k++){
							if(strItemIdsSplit[k]=="29" || strItemIdsSplit[k]=="30"){
									var checkFlag=true;
									var otherPtDataCheck=$scope.otherPtData;
									for(var i=0;i<otherPtDataCheck.length;i++) {
										var ido = otherPtDataCheck[i].ido;
										if(!$("#img_otherPt_"+ido).val() || !$("#img_otherPt_"+ido).val()){
											checkFlag=false;
											break;
										}
									}
									if(checkFlag){
										myFactory.alert('','体检报告留影不能为空!','info');
										return false;
									}
							}
						}
					}
				}
			    //S2018122906735移动保全新增变更项目及功能的优化需求 add by mqz 20200901 end
					
				return true;
			}

			//暂时不支持受益人和权益人并存的情况，除非提供受益人可以和具体的那些itemid并存
			function checkIsItemIdType(itemIdType) {
				var checkFlag="N";
				if ("" != strItemIds) {
					var itemIdTypeTemp="";
					var strItemIdsSplit = strItemIds.split(",");
					for(var k=0;k<strItemIdsSplit.length;k++){
						itemIdTypeTemp=strItemIdsSplit[k];
						if(itemIdTypeTemp==itemIdType){
							checkFlag="Y";
							break;
						}
					}
				}
				return checkFlag;
			}
	
			//S2018110706102 - 移动保全受理含“10-更改个人资料”的多项变更，客户签名留影缺失问题 add by csf 20181114  end
			//不存在：N，存在：（1）只存在身故收益人：Y_08_S,(2)存在身故受益人和其他可以并存的权益人：Y_08_M,(3)仅存在其他特殊可以和受益人并存的受益人：Y_08_D，（4）存在其他情况的受益人Y_08_O，在原方法体判断
			function checkIsBenefiItemIdType() {
				var returnResult="N";
				var checkFlag="N";
				var checkFlag_Y_08_S="N";
				var checkFlag_Y_08_B="N";
				var checkFlag_Y_08_D="N";
				//var checkFlag_Y_08_O="N";
				if ("" != strItemIds) {
					var itemIdTypeTemp="";
					var strItemIdsSplit = strItemIds.split(",");
					var lenItem=strItemIdsSplit.length;
					if(lenItem>0){
						for(var k=0;k<lenItem;k++){
							itemIdTypeTemp=strItemIdsSplit[k];
							if(itemIdTypeTemp=="08"){//受益人
								checkFlag_Y_08_S="Y";
								checkFlag="Y";
							}
							//50年金领取方式变更，39生存给付确认，40生存领取方式变更，47生存金领取，43满期金领取  可以和身故受益人并存
							if(itemIdTypeTemp=="50" || itemIdTypeTemp=="39" || itemIdTypeTemp=="40" || itemIdTypeTemp=="47" || itemIdTypeTemp=="43"){//权益人
								checkFlag_Y_08_B="Y";
								checkFlag="Y";
							}
						}
					}
				}
				if(checkFlag=="Y"){
					if(checkFlag_Y_08_S=="Y" && checkFlag_Y_08_B!="Y"){
						returnResult="Y_08_S";
					}else if(checkFlag_Y_08_S!="Y" && checkFlag_Y_08_B=="Y"){
						returnResult="Y_08_B";
					}else if(checkFlag_Y_08_S=="Y" && checkFlag_Y_08_B=="Y"){
						returnResult="Y_08_D";
					}else{
						returnResult="N";
					}
				}

				return returnResult;
			}

			//重新受理
			$scope.renew = function(){
				$interval.cancel($scope.data.timePhoto);
				myFactory.renew();
			}
			//退出移动保全
			$scope.exit = function(){
				$interval.cancel($scope.data.timePhoto);
				myFactory.exit();
			}
			//返回上一页
			$scope.goBack = function(){
				//myFactory.goBack();
				//留影返回上一步骤必须重新计算
				$interval.cancel($scope.data.timePhoto);//返回上一步时停止倒计时
				$ionicHistory.clearCache().then(function(){
					$state.go('photo_sign',{
						itemId:itemId,
						chdrnum01:chdrnum01,
						chdrcoy:chdrcoy,
						signMainData:signMainData
					});
				})
			}

			//保单详情
			$scope.showPolicyDetail = function(){
				modal('open','policyModalOnPhInput','policyWindowOnPhInput','policyCloseXOnPhInput');
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				//初始化查询订单详情
				var policyData;
				$http({
					method: 'GET',
					url: app.domain + 'query/restFindPolicyDetail.action',
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						policyData = response.data.data;
						$scope.policyData = policyData;
						$scope.policyData.ptdate01=myFactory.DateTools($scope.policyData.ptdate01);
					}
				}, function errorCallback(response) {
					$.alert({
						title: '',
						text: '初始化查询订单详情失败!',
						onOK: function () {
							//点击确认
						}
					});
				});
			}

			//保单详情弹窗关闭
			$scope.policyCancelOnPhInput = function(){
				modal('close','policyModalOnPhInput','policyWindowOnPhInput','policyCloseXOnPhInput');
			}
			
			//图片预览
			$scope.photo_preview = function(id){
				$("#photo_preview1").show();
				var src = $("#"+id).attr("src");
				$("#photo_preview1 .big_photo").attr({"src":src});
				$("#photo_preview1").click(function(){
					$(this).hide();
				});
			}
			
			//转换日期方法  例如：20170225--->2017-02-25 by zzq 2018-3-6
			function DateTools(date){
				date = String(date) ;
				if($.trim(date)!=""){
					return date.replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3");
				}else{
					return date;
				}
			}
			
			//拍照日志
			$scope.writePhotoLog = function(logParam){
				/*var logParam={
						"curentPtId":curentPtId,
						"photoDataLog":data
				};*/
				var photoItems={"photoItems":logParam};
				var token=sessionStorage.getItem("token");
				var timestamp=myFactory.getTimetamp();
				var sfis= "token-timestamp";
				var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				$http({
					method: 'post',
					url: app.domain + 'img/writePhotoLog.action',
					data:{paramsMap:photoItems,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						console.log("writePhotoLog ok");
					}
				}, function errorCallback(response) {
					console.log("writePhotoLog error");
				});
			}
			
			//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 begin
			//根据名字获取正面反面照片base64
			$scope.autoSetItem08IdPic = function(){
				var checkFlag08=checkIsItemIdType("08");//存在身故受益人则获取名字信息
				if(checkFlag08=="Y") {//身故受益人
					var benefiIdPtData=$scope.benefiIdPtData;
					var benefiIdPtDataLen=benefiIdPtData.length;
					if(benefiIdPtDataLen>0){
						//数组参数
						for(var i=0;i < benefiIdPtDataLen;i++){
							name=benefiIdPtData[i].name;
							ida=benefiIdPtData[i].ida;
							idb=benefiIdPtData[i].idb;
							setBenefitBase64Img(name,ida,idb);
						}
					}
				}
			}
			function setBenefitBase64Img(name,ida,idb){
				var itemIdCard08List=photoMainData.itemIdCard08List;
				if(itemIdCard08List!=null & itemIdCard08List!="" && itemIdCard08List.length>0){
					for(var i=0;i < itemIdCard08List.length;i++){
						var bfName=itemIdCard08List[i].bfName;
						var idCardBase64Img0=itemIdCard08List[i].idCardBase64Img0;
						var idCardBase64Img1=itemIdCard08List[i].idCardBase64Img1;
						if(name==bfName){
							if(idCardBase64Img0!=null && idCardBase64Img0!=""){
								$("#img_benefiIdPt_"+ida).attr('src','data:image/gif;base64,'+idCardBase64Img0);
								$("#benefiIdPt_"+ida).val(idCardBase64Img0);
								$("#img_benefiIdPt_"+ida).css('display','inline');
								$("#photo_cover_"+ida).css('display','none');
								$("#text_cover_"+ida).css('display','none');
								$("#delImg_"+ida).css('display','inline');
								
								/*$("#img_benefiIdPt_505_a0").attr('src','data:image/gif;base64,'+testVal);
								$("#benefiIdPt_505_a0").val(testVal);
								$("#img_benefiIdPt_505_a0").css('display','inline');
								$("#photo_cover_505_a0").css('display','none');
								$("#text_cover_505_a0").css('display','none');
								$("#delImg_505_a0").css('display','inline');*/
							}
							if(idCardBase64Img1!=null && idCardBase64Img1!=""){
								$("#img_benefiIdPt_"+idb).attr('src','data:image/gif;base64,'+idCardBase64Img1);
								$("#benefiIdPt_"+idb).val(idCardBase64Img1);
								$("#img_benefiIdPt_"+idb).css('display','inline');
								$("#photo_cover_"+idb).css('display','none');
								$("#text_cover_"+idb).css('display','none');
								$("#delImg_"+idb).css('display','inline');
							}
							break;
						}
					}
				}
			}
			function autoSetItem10IdPic(){
				var itemIdCard10_ow_img0=photoMainData.itemIdCard10_ow_img0;
				var itemIdCard10_ow_img1=photoMainData.itemIdCard10_ow_img1;
				var itemIdCard10_lf_img0=photoMainData.itemIdCard10_lf_img0;
				var itemIdCard10_lf_img1=photoMainData.itemIdCard10_lf_img1;
				
				//alert("itemIdCard10_ow_img0"+itemIdCard10_ow_img0);
				
				setItem10Base64Img(itemIdCard10_ow_img0,"ow","501a");
				setItem10Base64Img(itemIdCard10_ow_img1,"ow","501b");
				setItem10Base64Img(itemIdCard10_lf_img0,"lf","503a");
				setItem10Base64Img(itemIdCard10_lf_img1,"lf","503b");
			}
			function setItem10Base64Img(itemIdCardImg,role,id){
				if(itemIdCardImg!=null && itemIdCardImg!=""){
					if(role=='ow'){
						$("#img_policyHolderIdPt_"+id).attr('src','data:image/gif;base64,'+itemIdCardImg);
						$("#policyHolderIdPt_"+id).val(itemIdCardImg);
						$("#img_policyHolderIdPt_"+id).css('display','inline');
						$("#photo_cover_"+id).css('display','none');
						$("#text_cover_"+id).css('display','none');
						$("#delImg_"+id).css('display','inline');
					}
					if(role=='lf'){
						$("#img_insuredIdPt_"+id).attr('src','data:image/gif;base64,'+itemIdCardImg);
						$("#insuredIdPt_"+id).val(itemIdCardImg);
						$("#img_insuredIdPt_"+id).css('display','inline');
						$("#photo_cover_"+id).css('display','none');
						$("#text_cover_"+id).css('display','none');
						$("#delImg_"+id).css('display','inline');
					}
				}
			}
			
			
			//活体检测/人脸识别
			 $scope.faceVerify = function(context_id,typeName,role){
				if($scope.isPhotoOpenFlag){
					$scope.isPhotoOpenFlag=false;
					setTimeout(function() {
						$scope.isPhotoOpenFlag=true;
					}, 350);
				}else{
					return false;
				}
				
				if(maxTime==0){//如果超出时间限制测不能再拍照
					myFactory.alert('','拍摄超时，请返回上一步重新处理','info');
					return false;
				}
				
				//人脸核身调用调用的接口： 
				//无需参数 
				var data = {}; 
				
				if(curentPtId!=""){
					curentPtId="";
					curentPtTypeName="";
					curentPtRole="";
					appVersionPlat="";
				}
				curentPtId=context_id;
				curentPtTypeName=typeName;
				curentPtRole=role;

				var photoValTemp=$("#"+typeName+"_"+context_id).val();
				if(photoValTemp!=""){
					console.log("there ware a pic");
					return false;
				}
				
				/*if(maxTime==0){//如果超出时间限制测不能再拍照
					myFactory.alert('','拍摄超时，请返回上一步重新处理','info');
					return false;
				}*/
				
				var appVersionFlag = myFactory.getBrowserType();
				console.log("appVersionFlag:"+appVersionFlag);
				if(appVersionFlag=="Android"){
				}else if(appVersionFlag=="IOS"){
				}else if(appVersionFlag=="Browser_test"){
					$("#face_img_"+typeName+"_"+context_id).attr('src','data:image/gif;base64,'+testVal);
					$("#"+typeName+"_"+context_id).val(testVal);
					$("#face_img_"+typeName+"_"+context_id).css('display','inline');
					$("#face_photo_cover_"+context_id).css('display','none');
					$("#face_text_cover_"+context_id).css('display','none');
					$("#face_delImg_"+context_id).css('display','inline');
					//$("#policyHolderPt_500").val(resultImage);
					//$("#insuredPt_502").val(resultImage);
					return false;
				}
				appVersionPlat=appVersionFlag;
				//回调函数 
				/*var callBackFun_livingVerify = function(result){ 
					if(result.data.isSuccess){ 
						var verificationData = result.data.verficationData; 
						//大礼包——该数据是需要后面做人正合一使用的 
						
					}else{ 
						//活体检测原生"没通过" 
					} 
				};*/

				// S2023020825099 TX FaceID add by lvjg 20230625 start

				 var timestamp=myFactory.getTimetamp();
				 var sfis= "token-timestamp";
				 var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
				 var sign = myFactory.hex(signStr);
				 $http({
					 method: 'GET',
					 //timeout : 180000, //超时时间设置，单位毫秒
					 url: app.domain + 'img/isTencentFaceLive.action',
					 params: {'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				 }).then(function successCallback(response) {
					 console.log("isTencentFaceLive: " + response.data)
					 // 1 - 腾讯人脸识别
					 if (response.data == "1") {
						 console.log("role: " + role + ", ow_idTypeName: " + photoMainData.ow_idTypeName + ", lf_idTypeName: " + photoMainData.lf_idTypeName);
						 // 非身份证调用静态活体
						 if (("ow"==role && photoMainData.ow_idTypeName!="身份证") || ("lf"==role && photoMainData.lf_idTypeName!="身份证")) {
							 var photoData = {
								 "openFromGallery" : false,//是否从相册选择照片：true:从相册中选择，false:拍照
								 "imgType" : 'OtherPhoto'//固定值，千万不要改动
							 };
							 cordova.sino.takePhotoOther(callBackFun_Photo_tx, photoData)
						 } else {
							 var face_name;
							 var face_idNo;

							 if (role == "ow") {
								 face_name = face_ow_name;
								 face_idNo = face_ow_idno;
							 } else if (role == "lf"){
								 face_name = face_lf_name;
								 face_idNo = face_lf_idno;
							 }

							 var token=sessionStorage.getItem("token");
							 var timestamp=myFactory.getTimetamp();
							 var sfis= "token-timestamp";
							 var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
							 var sign = myFactory.hex(signStr);
							 $http({
								 method: 'POST',
								 //timeout : 180000, //超时时间设置，单位毫秒
								 url: app.domain + 'img/getTxFaceId.action',
								 data: {
									 'name':face_name,
									 'idNo':face_idNo,
									 'sign':sign,
									 'sfis':sfis,
									 'token':token,
									 'timestamp':timestamp
								 }
							 }).then(function successCallback(response) {
								 console.log(response.data)
								 data = response.data;
								 data["xType"] = "LivenessDetection";
								 console.log("请求XYT参数");
								 console.log(data)

								 /**
								  * callBackFun_livingVerify:回调函数  ，data：参数，目前可不用传
								  */
								 cordova.sino.LivenessDetection(callBackFun_faceVerify_tx, data);//信易通活体检测接口

							 }, function errorCallback(response) {
								 console.log("getTxFaceId error");
								 myFactory.alert('','获取人脸信息失败','info');
								 myFactory.loadingHide();
								 //myFactory.alert("","身份信息校验发生异常!","info");
							 });
						 }
					 } else {
						 /**
						  * callBackFun_livingVerify:回调函数  ，data：参数，目前可不用传
						  */
						 cordova.sino.LivenessDetection(callBackFun_faceVerify, data);//信易通活体检测接口
					 }

				 }, function errorCallback(response) {
					 console.log("isTencentFaceLive error");
					 myFactory.loadingHide();
					 //myFactory.alert("","身份信息校验发生异常!","info");
				 });

				// S2023020825099 TX FaceID add by lvjg 20230625 end


				//callBackFun_faceVerify();//测试回调函数
			}

			// 腾讯静态活体检测回调函数
			var callBackFun_Photo_tx = function(result){
				console.log("腾讯静态活体检测----")
				console.log(result)

				var data = result.data;
				var val = data.Base64Img;//拍照数据

				var token=sessionStorage.getItem("token");
				var timestamp=myFactory.getTimetamp();
				var sfis= "token-timestamp";
				var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				$http({
					method: 'POST',
					//timeout : 180000, //超时时间设置，单位毫秒
					url: app.domain + 'img/detectLiveFace.action',
					data: {
						'Image':val,
						'sign':sign,
						'sfis':sfis,
						'token':token,
						'timestamp':timestamp
					}
				}).then(function successCallback(response) {

					var verificationData = val;
					var faceVerifyStatus=false;

					console.log(response.data)
					data = response.data;

					let errorMsg = data.errorMsg;
					if (typeof errorMsg == 'string' && errorMsg.length > 0){
						myFactory.alert('',errorMsg,'info');
					} else {
						let score = data.score;
						if (score >= 40) {
							console.log("TX静态人脸识别....校验通过!");
							faceVerifyStatus = true;
							if(curentPtRole=="ow"){
								verifyStatusOwFlag = true;
							}else if(curentPtRole=="lf"){
								verifyStatusLfFlag = true;
							}

							if(curentPtRole=="ow"){
								$("#face_img_policyHolderPt_500").attr('src','data:image/gif;base64,'+verificationData);
								$("#policyHolderPt_500").val(verificationData);
								$("#face_img_policyHolderPt_500").css('display','inline');
								$("#face_photo_cover_500").css('display','none');
								$("#face_text_cover_500").css('display','none');
								$("#face_delImg_500").css('display','inline');
								$("#checkImg_500").css('display','none');
							}else if(curentPtRole=="lf"){
								$("#face_img_insuredPt_502").attr('src','data:image/gif;base64,'+verificationData);
								$("#insuredPt_502").val(verificationData);
								$("#face_img_insuredPt_502").css('display','inline');
								$("#face_photo_cover_502").css('display','none');
								$("#face_text_cover_502").css('display','none');
								$("#face_delImg_502").css('display','inline');
								$("#checkImg_502").css('display','none');
							}
						} else {
							faceVerifyStatus = false;
							myFactory.alert('','人脸识别不通过','info');
						}

						var verifyStatus = faceVerifyStatus ? "0" : "1";
						console.log("faceVerifyStatus : " + faceVerifyStatus)
						console.log("verifyStatus : " + verifyStatus)
						var imgId = "";

						if (curentPtRole == "ow") {
							imgId = "checkImg_500";
						}
						if (curentPtRole == "lf") {
							imgId = "checkImg_502";
						}

						updateVerifyResult(imgId,verifyStatus);
					}
				}, function errorCallback(response) {
					console.log("detectLiveFace error");
					myFactory.alert('','人脸活体校验失败','info');
					myFactory.loadingHide();
				});
			};

			// 腾讯活体检测回调函数
			var callBackFun_faceVerify_tx = function(result){

				var verificationData = "";
				var faceVerifyStatus=false;
				//var faceVerifyStatus=true;

				//test
				/*var result = {
						data: {
							isSuccess: "1",
							verificationData: verificationData
						}
				};*/
				console.log("TX活体检测结果----")
				console.log(result)
				if(result.data.isSuccess=="1"){
					verificationData = result.data.verificationData; //verficationData错误
					if(verificationData != undefined || verificationData != null || verificationData != ""){
						faceVerifyStatus = true;

						console.log("TX人证合一....身份信息校验通过!");
						if(curentPtRole=="ow"){
							verifyStatusOwFlag = true;
						}else if(curentPtRole=="lf"){
							verifyStatusLfFlag = true;
						}

						if(curentPtRole=="ow"){
							$("#face_img_policyHolderPt_500").attr('src','data:image/gif;base64,'+verificationData);
							$("#policyHolderPt_500").val(verificationData);
							$("#face_img_policyHolderPt_500").css('display','inline');
							$("#face_photo_cover_500").css('display','none');
							$("#face_text_cover_500").css('display','none');
							$("#face_delImg_500").css('display','inline');
							$("#checkImg_500").css('display','none');
						}else if(curentPtRole=="lf"){
							$("#face_img_insuredPt_502").attr('src','data:image/gif;base64,'+verificationData);
							$("#insuredPt_502").val(verificationData);
							$("#face_img_insuredPt_502").css('display','inline');
							$("#face_photo_cover_502").css('display','none');
							$("#face_text_cover_502").css('display','none');
							$("#face_delImg_502").css('display','inline');
							$("#checkImg_502").css('display','none');
						}

					} else {
						faceVerifyStatus = false;
						myFactory.alert('','人脸识别不通过','info');
					}
				}else{
					//活体检测原生"没通过"
					faceVerifyStatus=false;
					var errorMsg = result.data.sessionState;
					myFactory.alert('',errorMsg,'info');
				}

				var verifyStatus = faceVerifyStatus ? "0" : "1";
				console.log("faceVerifyStatus : " + faceVerifyStatus)
				console.log("verifyStatus : " + verifyStatus)
				var imgId = "";

				if (curentPtRole == "ow") {
					imgId = "checkImg_500";
				}
				if (curentPtRole == "lf") {
					imgId = "checkImg_502";
				}

				updateVerifyResult(imgId,verifyStatus);

			};
			
			//活体检测回调函数 
			var callBackFun_faceVerify = function(result){ 
			//var callBackFun_faceVerify = function(){ 
				
				/*alert("人脸识别返回数据result print："+JSON.stringify(result));
				alert("人脸识别返回数据result："+result);
				alert("人脸识别返回数据result.data："+result.data);
				alert("人脸识别返回数据result.data print："+JSON.stringify(result.data));
				alert("人脸识别返回数据result.data.isSuccess："+result.data.isSuccess);
				alert("人脸识别返回数据verificationData："+result.data.verificationData);
				alert("人脸识别返回数据verficationData："+result.data.verficationData);*/
				
				//var verificationData = "verificationData_big_data";
				var verificationData = "";
				var faceVerifyStatus=false;
				//var faceVerifyStatus=true;
				
				//test
				/*var result = {
						data: {
							isSuccess: "1",
							verificationData: verificationData
						}
				};*/
				if(result.data.isSuccess=="1"){ 
					verificationData = result.data.verificationData; //verficationData错误
					//大礼包——该数据是需要后面做人正合一使用的 
					if(verificationData!=undefined || verificationData!=null || verificationData!=""){
						faceVerifyStatus=true;
					}
				}else{ 
					//活体检测原生"没通过" 
					faceVerifyStatus=false;
				}
				
				/***************writePhotoLog begin******************/
				/*var callXytParam="curentPtId="+curentPtId+",curentPtRole="+curentPtRole+",调用信易通方法：cordova.sino.LivenessDetection(callBackFun_faceVerify, data),参数值内容data[]";
				var logParam={
						"opType":"faceVerify",
						"curentPtId":callXytParam,
						"chdrnum":chdrnum01,
						"photoDataLog":verificationData
				};
				$scope.writePhotoLog(logParam);*/
				/***************writePhotoLog end******************/
				
				if(verificationData==undefined || verificationData==null || verificationData==""){
					return false;
				}else{
					/*if(faceVerifyStatus){//人脸识别通过，根据证件类型做人证合一校验 
						//人证合一校验
						$scope.faceIdCardVerifyIterval(verificationData);
					}else{//人脸识别失败*/		
					//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 start
					 //因为所有证件都需要活体检测，所以需要判断是否时身份证，是的话才需要进行人证合一的检测，不是的话，需要调用思图新的接口,进行验证返回照片
					if(faceVerifyStatus && photoMainData.ow_idTypeName=="身份证"){
						//人证合一校验
						$scope.faceIdCardVerifyIterval(verificationData);
						//测试csf
					} else if(faceVerifyStatus && photoMainData.ow_idTypeName!="身份证"){//其他证件，走新的接口，返回的数据进行照片的填充
						//正式
						$scope.faceContrast(verificationData);
						
						//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 end

						
					}else{//人脸识别失败
						//S2018091005428-移动保全人脸核身优化需求 ,任何证件类型都需要走活体检测 add by csf 20181128 end
						if(curentPtRole=="ow"){
							updateVerifyResult('checkImg_500',"1");
						}else if(curentPtRole=="lf"){
							updateVerifyResult('checkImg_502',"1");
						}
						//myFactory.alert("","人脸识别不通过,请重新校验!","info");
					}
				}
			};
			
			//异步调用人证合一接口，用Iterval间接实现angular开启另一个线程
			$scope.faceIdCardVerifyIterval = function(verificationData){
				myFactory.loadingShow();//人证合一校验等待滚动：信易通也是，但是信易通照片都没有返回
				console.log("faceWitnessVerify test...........");
				/*$http({
					method: 'GET',
					url: app.domain + 'img/faceWitnessVerify.action'
				}).then(function successCallback(response) {
					if (response.data.success) {
						//var message = response.data.data.message;
						//console.log("人脸识别成功....."+message);
					}
				}, function errorCallback(response) {
					myFactory.alert("","人脸识别失败!","info");
				});*/
				
				var itemVerify = {
						chdrnum : chdrnum01,
	        			role : curentPtRole,
	        			appVersionPlat : appVersionPlat,
	        			imagePackage : ""
	        	};
				//verificationData = testVal;//测试
				itemVerify.imagePackage=verificationData;
				verificationData="";//清空verificationData大礼包
				
				var itemVerifys={"itemVerify":itemVerify};
				var token=sessionStorage.getItem("token");
				var timestamp=myFactory.getTimetamp();
				var sfis= "token-timestamp";
				var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				//证件类型为身份证，则需要进行人证合一校验
				$http({
				    method: 'POST',
	                //timeout : 180000, //超时时间设置，单位毫秒
	                url: app.domain + 'img/faceIdCardVerify.action',
	                data: {paramsMap:itemVerifys,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}						
				    //data: itemVerify						
				}).then(function successCallback(response) {
					if (response.data.success) {
						//人证合一状态：校验通过0、校验不通过1、不需校验2，校验发生异常-1/-2
						var verifyStatus = response.data.data.verifyStatus;
						console.log("人证合一校验状态....."+verifyStatus);
						if(verifyStatus=="0"){
							if(curentPtRole=="ow"){
								verifyStatusOwFlag=true;
							}else if(curentPtRole=="lf"){
								verifyStatusLfFlag=true;
							}
							//myFactory.alert("","身份信息校验通过!","info");
							console.log("人证合一....身份信息校验通过!");
							
							if(curentPtRole=="ow"){
								var resultImage = response.data.data.resultImage;
								$("#face_img_policyHolderPt_500").attr('src','data:image/gif;base64,'+resultImage);
								$("#policyHolderPt_500").val(resultImage);
								$("#face_img_policyHolderPt_500").css('display','inline');
								$("#face_photo_cover_500").css('display','none');
								$("#face_text_cover_500").css('display','none');
								$("#face_delImg_500").css('display','inline');
								$("#checkImg_500").css('display','none');
							}else if(curentPtRole=="lf"){
								var resultImage = response.data.data.resultImage;
								$("#face_img_insuredPt_502").attr('src','data:image/gif;base64,'+resultImage);
								$("#insuredPt_502").val(resultImage);
								$("#face_img_insuredPt_502").css('display','inline');
								$("#face_photo_cover_502").css('display','none');
								$("#face_text_cover_502").css('display','none');
								$("#face_delImg_502").css('display','inline');
								$("#checkImg_502").css('display','none');
							}
							if(curentPtRole=="ow"){
								updateVerifyResult('checkImg_500',"0");
							}else if(curentPtRole=="lf"){
								updateVerifyResult('checkImg_502',"0");
							}
						}else{
							if(curentPtRole=="ow"){
								verifyStatusOwFlag=false;
								updateVerifyResult('checkImg_500',"1");
							}else if(curentPtRole=="lf"){
								verifyStatusLfFlag=false;
								updateVerifyResult('checkImg_502',"1");
							}
							console.log("人证合一....身份信息校验不通过!");
							myFactory.alert('','人脸识别不通过','info');
						}
					}
					myFactory.loadingHide();
				}, function errorCallback(response) {
					console.log("faceVerify error");
					myFactory.loadingHide();
					//myFactory.alert("","身份信息校验发生异常!","info");
				});
				//return false;
				
				//var maxTime=30;
				//$scope.textFlag = true;
				//$scope.faceIterval = $interval(function(){

					//maxTime--;
					//console.log("timePhoto2:"+maxTime);
					
					//$scope.httpTimeTest();
					
					/*if (maxTime < 1) {
						$interval.cancel($scope.faceIterval);
					} else {
						//$scope.data.timeRest = maxTime;
					}

					if(maxTime==0){
						return false;
					}*/
					
				//}, 1000,1);
			}
			//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 start
			//调用思图新接口进行人脸验证，返回图片
			$scope.faceContrast = function(verificationData){
				myFactory.loadingShow();//人证合一校验等待滚动：信易通也是，但是信易通照片都没有返回
				console.log("faceWitnessVerify test...........");
				var itemVerify = {
						chdrnum : chdrnum01,
	        			role : curentPtRole,
	        			appVersionPlat : appVersionPlat,
	        			imagePackage : ""
	        	};
				//verificationData = testVal;//测试
				itemVerify.imagePackage=verificationData;
				verificationData="";//清空verificationData大礼包
				
				var itemVerifys={"itemVerify":itemVerify};
				var token=sessionStorage.getItem("token");
				var timestamp=myFactory.getTimetamp();
				var sfis= "token-timestamp";
				var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				$http({
				    method: 'POST',
	                url: app.domain + 'img/faceIdCardVerify.action',
	                data: {paramsMap:itemVerifys,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}										
				}).then(function successCallback(response) {
					if (response.data.success) {
						//人证合一状态：校验通过0、校验不通过1
						var verifyStatus = response.data.data.verifyStatus;
						console.log("人证合一校验状态....."+verifyStatus);
						if(verifyStatus=="0"){
							if(curentPtRole=="ow"){
								verifyStatusOwFlag=true;
							}else if(curentPtRole=="lf"){
								verifyStatusLfFlag=true;
							}		
							if(curentPtRole=="ow"){
								var resultImage = response.data.data.resultImage;
								$("#face_img_policyHolderPt_500").attr('src','data:image/gif;base64,'+resultImage);
								$("#policyHolderPt_500").val(resultImage);
								$("#face_img_policyHolderPt_500").css('display','inline');
								$("#face_photo_cover_500").css('display','none');
								$("#face_text_cover_500").css('display','none');
								$("#face_delImg_500").css('display','inline');
								$("#checkImg_500").css('display','none');
							}else if(curentPtRole=="lf"){
								var resultImage = response.data.data.resultImage;
								$("#face_img_insuredPt_502").attr('src','data:image/gif;base64,'+resultImage);
								$("#insuredPt_502").val(resultImage);
								$("#face_img_insuredPt_502").css('display','inline');
								$("#face_photo_cover_502").css('display','none');
								$("#face_text_cover_502").css('display','none');
								$("#face_delImg_502").css('display','inline');
								$("#checkImg_502").css('display','none');
							}
							if(curentPtRole=="ow"){
								updateVerifyResult('checkImg_500',"0");
							}else if(curentPtRole=="lf"){
								updateVerifyResult('checkImg_502',"0");
							}
						}else{
							if(curentPtRole=="ow"){
								verifyStatusOwFlag=false;
								updateVerifyResult('checkImg_500',"1");
							}else if(curentPtRole=="lf"){
								verifyStatusLfFlag=false;
								updateVerifyResult('checkImg_502',"1");
							}
							myFactory.alert('','人脸识别不通过','info');
						}
					}
					myFactory.loadingHide();
				}, function errorCallback(response) {
					myFactory.loadingHide();
				});
			}
			//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128  end
			//人脸识别结果勾显示成功或者失败状态
			function updateVerifyResult(id,faceVerifyStatus){
				$("#"+id).show();
				if(faceVerifyStatus=="0"){
					$("#"+id).attr({"src":"images/face_success.png"});
				}else{
					$("#"+id).attr({"src":"images/face_fail.png"});
				}
			}
			
			//投保人、被保人人脸核身与拍照留影切换
			function facePageChange(idFs,idPt,idCheck){
				if($("#"+idFs).css("display")=="none"){
					$("#"+idFs).show();
					$("#"+idPt).hide();
					//去除勾或叉
					$("#"+idCheck).hide();
				}else{
					$("#"+idFs).hide();
					$("#"+idPt).show();
				}
			}
			
			$scope.item08IdPicIterval = function(){
				var maxTime=2;
				$scope.autoItem08IdPicIterval = $interval(function(){
					maxTime--;
					console.log("item08IdPicIterval begin...........maxTime="+maxTime);
					if (maxTime < 1) {
						$interval.cancel($scope.autoItem08IdPicIterval);
						//页面元素还没加载，借用倒计时线程来触发受益人自动化获取证件图片
						console.log("showProfitIdPtFlag"+$scope.showProfitIdPtFlag);
						if($scope.showProfitIdPtFlag){
							console.log("*************autoSetItem08IdPic begin*************");
							$scope.autoSetItem08IdPic();
							console.log("*************autoSetItem08IdPic end*************");
							//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 start
							console.log("*************autoSetItem08Date begin*************");
							$scope.autoSetItem08Date();
							console.log("*************autoSetItem08Date end*************");
							//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 end
						}
					}
				}, 1000,2);
			}
			
			//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 start
			$scope.autoSetItem08Date = function(){
				var checkFlag08=checkIsItemIdType("08");//存在身故受益人则获取名字信息
				if(checkFlag08=="Y") {//身故受益人
					var benefiIdPtData=$scope.benefiIdPtData;
					var benefiIdPtDataLen=benefiIdPtData.length;
					if(benefiIdPtDataLen>0){
						//数组参数
						var ida = "";
						var availDataStart = "";
						var availDataClose = "";
						for(var i=0;i < benefiIdPtDataLen;i++){
							ida=benefiIdPtData[i].ida;
							availDataStart = benefiIdPtData[i].availDataStart;
							availDataClose = benefiIdPtData[i].availDataClose;
							if(benefiIdPtData[i].idType!="1"){
								myFactory.initDateUtil('benfIdDateStart_'+ida,DateTools(availDataStart));
								if(benefiIdPtData[i].availDataType=="1"){
									myFactory.initDateUtil('benfIdDate_'+ida,"");
									$("#benfIdDate_"+benfIdDate_).val("");
								}else{
									myFactory.initDateUtil('benfIdDate_'+ida,DateTools(availDataClose));
								}
							}
						}
					}
				}
			}
			//S2023051626072港澳居民来往内地通行证有效期延长系统需求 update by huanghk 20230529 end

			//PC端开发测试用
			/*var testVal="R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7";
			var result = {
				data : {
					Name:"冯冠涛",
					Sex:"男",
					Birthday:"1990-05-27",
					//Id:"440771201503231715",
					Id:"441223199005274713",
					Address:"广东省广州市天河区某街道23号",
					Validity:"2050-08-23",
					//Validity:"长期",
					smallPic:testVal,
					bigPic:testVal,
					ok:"true",
					//isFront:true,//正面
					isFront:false,//反面
				}
			};*/
			//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 start
			//增加参数isFront， 用来判断点击扫描的页面区域是正面扫描还是反面进行的
			$scope.scanIdcardPictures = function(context_id,typeName,role,scanName,isFront){
			//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 end
				/*if($scope.isPhotoOCRFlag){
					$scope.isPhotoOCRFlag=false;
					setTimeout(function() {
						$scope.isPhotoOCRFlag=true;
					}, 350);
				}else{
					return false;
				}*/
				if(maxTime==0){//如果超出时间限制测不能再拍照
					myFactory.alert('','拍摄超时，请返回上一步重新处理','info');
					return false;
				}
				if("OW"==role && photoMainData.ow_idTypeName!="身份证"){
					$scope.takePictures(context_id,typeName);
				}else if("LF"==role && photoMainData.lf_idTypeName!="身份证"){
					$scope.takePictures(context_id,typeName);
				}else if("BF"==role){
					//根据人员scanName确定证件类型
					var benefitList=photoMainData.benefitList;
					var idType="";
					if(benefitList!=null & benefitList!="" && benefitList.length>0){
						for(var i=0;i < benefitList.length;i++){
							var bfName=benefitList[i].name;
							if(scanName==bfName){
								idType=benefitList[i].idType;
								break;
							}
						}
					}
					//alert("idType="+idType);
					if("1"!=idType){//证件类型非身份证，则拍照
						$scope.takePictures(context_id,typeName);
					}else{//受益人、证件OCR
						scanIDCardInfoPic(context_id,typeName,role,scanName,isFront);
					}
				}else{
					scanIDCardInfoPic(context_id,typeName,role,scanName,isFront);
				}
			}
			
			function scanIDCardInfoPic(context_id,typeName,role,scanName,isFront){
				if($scope.isPhotoOCRFlag){
					$scope.isPhotoOCRFlag=false;
					setTimeout(function() {
						$scope.isPhotoOCRFlag=true;
					}, 350);
				}else{
					return false;
				}
				$scope.curentPtBfName=scanName;
				if(curentPtId!=""){
					curentPtId="";
					curentPtTypeName="";
				}
				curentPtId=context_id;
				curentPtTypeName=typeName;
				
				var photoValTemp=$("#"+typeName+"_"+context_id).val();
				if(photoValTemp!=""){
					console.log("there ware a pic");
					return false;
				}
				//移动端
				cordova.sino.getIDCardInfo(function(result){
					if(result.success){
						if(!result.data.exit){
							if(appVersion==="IOS"){
								if(result.data.ok){
									//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 start
									//身份证正面只能扫描身份证正面信息，不能扫描反面，反之亦然
									if (isFront === 'Y'){
										//身份证正面
										//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 end
										if(result.data.isFront){

											//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
//											var name=result.data.Name;
//											var sex=result.data.Sex;
//											var birthday=result.data.Birthday;
											var id =result.data.Id;//证件号码
//											var address=result.data.Address;
											var idCardSmallPic=result.data.smallPic;
											var idCardBigPic=result.data.bigPic;
//											checkAndSetIdcardInfo(id,name,sex,birthday,role,curentPtId,curentPtTypeName,idCardBigPic,$scope.curentPtBfName);
											checkAndSetIdcardInfo(id,role,curentPtId,curentPtTypeName,idCardBigPic,$scope.curentPtBfName);
											//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
										} else {
											myFactory.alert('注意','证件正面区域只能扫描身份证正面，请重新扫描！','info');
											return
										}
									}else{
										//身份证反面
										//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 start
										if (isFront === 'N'){
											if(result.data.isFront){
												myFactory.alert('注意','证件反面区域只能扫描身份证反面，请重新扫描！','info');
												return
											}
										//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 end
										var validity=result.data.Validity;//有效期
										//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
										var oldValidity=result.data.OldValidity;//有效期
										var idCardSmallPic=result.data.smallPic;
										var idCardBigPic=result.data.bigPic;
										var isPerpetual = validity == '长期';
										//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
										if (checkFlag10 == 'Y'){
											if(!checkCradValidity(validity,role)){
												myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
												return;
											}
											if(!checkCradOldValidity(oldValidity,role)){
												myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
												return;
											}
										}
										
										if (checkFlag10 == 'N' && role =='BF'){
											if(!checkCradValidity(validity,role)){
												myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
												return;
											}
											if(!checkCradOldValidity(oldValidity,role)){
												myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
												return;
											}
											//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end

										}
										//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
										//信易通OCR身份证有效期校验 add by lb 20220926 start
										if ("OW" == role) {
											var owIdNo = photoMainData.ow_idNo;
											var brithDay = owIdNo.substr(6, 4) + "-" + owIdNo.substr(10, 2) + "-" + owIdNo.substr(12, 2);
											if (!checkIdCardDate(brithDay, oldValidity, validity)
												|| (!isPerpetual &&(!compareDate(getDate(validity),getDate(sysDate))
												|| compareDate(getDate(oldValidity),getDate(sysDate))
												|| !compareDate(getDate(oldValidity),getDate('20040329'))))
											) {
												myFactory.alert("", "投保人证件有效期错误，请核对信息，若不一致请重新拍照。", "info");
												return;
											}
										} else if ("LF" == role) {
											var lfIdNo = photoMainData.lf_idNo;
											var brithDay = lfIdNo.substr(6, 4) + "-" + lfIdNo.substr(10, 2) + "-" + lfIdNo.substr(12, 2);
											if (!checkIdCardDate(brithDay, oldValidity, validity)
												|| (!isPerpetual &&(!compareDate(getDate(validity),getDate(sysDate))
												|| compareDate(getDate(oldValidity),getDate(sysDate))
												|| !compareDate(getDate(oldValidity),getDate('20040329'))))
											) {
												myFactory.alert("", "被保人证件有效期错误，请核对信息，若不一致请重新拍照。", "info");
												return;
											}
										} else if ("BF" == role) {
											var benefitList = photoMainData.benefitList;
											var birthday = "";
											if (benefitList != null && benefitList != "" && benefitList.length > 0) {
												for (var i = 0; i < benefitList.length; i++) {
													if ($scope.curentPtBfName == benefitList[i].name) {
														birthday = benefitList[i].birthDay;
														break;
													}
												}
											}
											if (!checkIdCardDate(birthday, oldValidity, validity)
												|| (!isPerpetual && (!compareDate(getDate(validity),getDate(sysDate))
												|| compareDate(getDate(oldValidity),getDate(sysDate))
												|| !compareDate(getDate(oldValidity),getDate('20040329'))))
											) {
												myFactory.alert("", "受益人【" + $scope.curentPtBfName + "】证件有效期错误，请核对信息，若不一致请重新拍照。", "info");
												return;
											}
										}
										//信易通OCR身份证有效期校验 add by lb 20220926 end
										
										//存在有效期为长期的情况：
										if("OW"==role){
											var ow_availDataType="";
											//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
											var ow_availDataStart="";
											//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
											var ow_availDataClose="";
											if(validity=='长期' || validity=='终身'){
												ow_availDataType="1";
												//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
												ow_availDataStart=oldValidity;
												ow_availDataClose="";
												//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
											}else{
												ow_availDataType="2";
												//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
												ow_availDataStart=oldValidity;
												//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
												ow_availDataClose=validity;  
											}
											$("#holderIdDateType").val(ow_availDataType);
											$scope.holderIdDateTypeSelect = ow_availDataType;
											var options_holder =$("#holderIdDateType option:selected");
											$scope.holderCreTypeName=options_holder.text();
											//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
											$scope.photoMainData.ow_availDataStart=ow_availDataStart;
											myFactory.initDateUtil('holderIdDateStart',ow_availDataStart);
											if(ow_availDataType=="1"){
												$scope.photoMainData.ow_availDataClose="";
												myFactory.initDateUtil('holderIdDate','');
												$("#holderIdDate").val("");
											}else{
												$scope.photoMainData.ow_availDataClose=ow_availDataClose;
												myFactory.initDateUtil('holderIdDate',ow_availDataClose);
											}
										}else if("LF"==role){
											var lf_availDataType="";
											 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
											var lf_availDataStart="";
											var lf_availDataClose="";
											if(validity=='长期' || validity=='终身'){
												lf_availDataType="1";
												lf_availDataStart=oldValidity;
												lf_availDataClose="";
											}else{
												lf_availDataType="2";
												lf_availDataStart=oldValidity;
												 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
												lf_availDataClose=validity;
											}
											$("#insuredIdDateType").val(lf_availDataType);
											$scope.insuredIdDateTypeSelect = lf_availDataType;
											var options_insured =$("#insuredIdDateType option:selected");
											$scope.insuredCreTypeName=options_insured.text();
											myFactory.initDateUtil('insuredIdDate','');
											
											//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
											$scope.photoMainData.lf_availDataStart=lf_availDataStart;
											myFactory.initDateUtil('insuredIdDateStart',lf_availDataStart);
											if(lf_availDataType=="1"){
												$scope.photoMainData.lf_availDataClose="";
												myFactory.initDateUtil('insuredIdDate','');
												$("#insuredIdDate").val("");
											}else{
												$scope.photoMainData.lf_availDataClose=lf_availDataClose;
												myFactory.initDateUtil('insuredIdDate',lf_availDataClose);
											}
											 //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end

										//信易通OCR身份证有效期校验 add by lb 20220926 start
										}else if("BF"==role){
											var bf_availDataType="";
											var bf_availDataStart="";
											var bf_availDataClose="";
											if(validity=='长期' || validity=='终身'){
												bf_availDataType="1";
												bf_availDataStart=oldValidity;
											}else{
												bf_availDataType="2";
												bf_availDataStart=oldValidity;
												bf_availDataClose=validity;
											}
											var benefitList = $scope.benefiIdPtData;
											if (benefitList != null && benefitList != "" && benefitList.length > 0) {
												for (var i = 0; i < benefitList.length; i++) {
													if ($scope.curentPtBfName == benefitList[i].name) {
														benefitList[i].availDataType = bf_availDataType;
														benefitList[i].availDataTypeCN = bf_availDataType == '2' ? '年期' : '长期';
														benefitList[i].availDataStart = bf_availDataStart;//有效期起始日
														benefitList[i].availDataClose = bf_availDataClose;//有效期截至日
														break;
													}
												}
											}
										}
										//信易通OCR身份证有效期校验 add by lb 20220926 end
										setIdCardPic(curentPtId,curentPtTypeName,idCardBigPic);
									}
								}
								}
							}else{
								$scope.smallPic=result.data.smallPic;
					            $scope.bigPic=result.data.bigPic;
					            result.data.smallPic="";
								result.data.bigPic="";
								cordova.sino.confirmIDCardInfo(function(result){
									if(result.success){
										if(result.data.ok){
											//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 start
											//身份证正面只能扫描身份证正面信息，不能扫描反面，反之亦然
											if (isFront === 'Y'){
												//身份证正面
												//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 end
											if(result.data.isFront){
												//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
//												var name=result.data.Name;
//												var sex=result.data.Sex;
//												var birthday=result.data.Birthday;
												var id =result.data.Id;//证件号码
//												var address=result.data.Address;
												
//												checkAndSetIdcardInfo(id,name,sex,birthday,role,curentPtId,curentPtTypeName,$scope.bigPic,$scope.curentPtBfName);
												checkAndSetIdcardInfo(id,role,curentPtId,curentPtTypeName,$scope.bigPic,$scope.curentPtBfName);

												//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
												$scope.smallPic="";
												$scope.bigPic="";
												} else {
													myFactory.alert('注意','证件正面区域只能扫描身份证正面，请重新扫描！','info');
													return
												}
											}else{
												//身份证反面
												//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 start
												if (isFront === 'N'){
													if(result.data.isFront){
														myFactory.alert('注意','证件反面区域只能扫描身份证反面，请重新扫描！','info');
														return
													}
												//S2018091005428-移动保全人脸核身优化需求 add by csf 20181128 end
												//身份证反面
												var validity=result.data.Validity;//有效期
											     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
												var oldValidity=result.data.OldValidity;//有效期
											     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
												var isPerpetual = validity == '长期';
												//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
												if (checkFlag10 == 'Y'){
													if(!checkCradValidity(validity,role)){
														myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
														return;
													}
												     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
													if(!checkCradOldValidity(oldValidity,role)){
														myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
														return;
													}
												}
												
												if (checkFlag10 == 'N' && role =='BF'){
													if(!checkCradValidity(validity,role)){
														myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
														return;
													}
													if(!checkCradOldValidity(oldValidity,role)){
														myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
														return;
													}
												     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
												}
												//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end

												//信易通OCR身份证有效期校验 add by lb 20220926 start
												if ("OW" == role) {
													var owIdNo = photoMainData.ow_idNo;
													var brithDay = owIdNo.substr(6, 4) + "-" + owIdNo.substr(10, 2) + "-" + owIdNo.substr(12, 2);
													if (!checkIdCardDate(brithDay, oldValidity, validity)
														|| (!isPerpetual &&(!compareDate(getDate(validity),getDate(sysDate))
														|| compareDate(getDate(oldValidity),getDate(sysDate))
														|| !compareDate(getDate(oldValidity),getDate('20040329'))))
													) {
														myFactory.alert("", "投保人证件有效期错误，请核对信息，若不一致请重新拍照。", "info");
														return;
													}
												} else if ("LF" == role) {
													var lfIdNo = photoMainData.lf_idNo;
													var brithDay = lfIdNo.substr(6, 4) + "-" + lfIdNo.substr(10, 2) + "-" + lfIdNo.substr(12, 2);
													if (!checkIdCardDate(brithDay, oldValidity, validity)
														|| (!isPerpetual &&(!compareDate(getDate(validity),getDate(sysDate))
														|| compareDate(getDate(oldValidity),getDate(sysDate))
														|| !compareDate(getDate(oldValidity),getDate('20040329'))))
													) {
														myFactory.alert("", "被保人证件有效期错误，请核对信息，若不一致请重新拍照。", "info");
														return;
													}
												} else if ("BF" == role) {
													var benefitList = photoMainData.benefitList;
													var birthday = "";
													if (benefitList != null && benefitList != "" && benefitList.length > 0) {
														for (var i = 0; i < benefitList.length; i++) {
															if ($scope.curentPtBfName == benefitList[i].name) {
																birthday = benefitList[i].birthDay;
																break;
															}
														}
													}
													if (!checkIdCardDate(birthday, oldValidity, validity)
														|| (!isPerpetual &&(!compareDate(getDate(validity),getDate(sysDate))
														|| compareDate(getDate(oldValidity),getDate(sysDate))
														|| !compareDate(getDate(oldValidity),getDate('20040329'))))
													) {
														myFactory.alert("", "受益人" + $scope.curentPtBfName + "证件有效期错误，请核对信息，若不一致请重新拍照。", "info");
														return;
													}
												}
												//信易通OCR身份证有效期校验 add by lb 20220926 end
												
												//checkAndSetIdcardInfo(id,name,sex,birthday,role,curentPtId,curentPtTypeName,idCardBigPic);
												//存在有效期为长期的情况：
												if("OW"==role){
													var ow_availDataType="";
													var ow_availDataClose="";
											 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
													var ow_availDataStart="";
											 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
													if(validity=='长期' || validity=='终身'){
														ow_availDataType="1";
														//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
														ow_availDataStart=oldValidity;
														ow_availDataClose="";
													    //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
													}else{
														ow_availDataType="2";
													     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
														ow_availDataStart=oldValidity;
													     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
														ow_availDataClose=validity;
													}
													$("#holderIdDateType").val(ow_availDataType);
													$scope.holderIdDateTypeSelect = ow_availDataType;
													var options_holder =$("#holderIdDateType option:selected");
													$scope.holderCreTypeName=options_holder.text();
													//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
													$scope.photoMainData.ow_availDataStart=ow_availDataStart;
													myFactory.initDateUtil('holderIdDateStart',ow_availDataStart);
													if(ow_availDataType=="1"){
														$scope.photoMainData.ow_availDataClose="";
														myFactory.initDateUtil('holderIdDate','');
														$("#holderIdDate").val("");
													}else{
														$scope.photoMainData.ow_availDataClose=ow_availDataClose;
														myFactory.initDateUtil('holderIdDate',ow_availDataClose);
													}
											 	     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
												}else if("LF"==role){
													var lf_availDataType="";
													var lf_availDataClose="";
													if(validity=='长期' || validity=='终身'){
														lf_availDataType="1";
														//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
														lf_availDataStart=oldValidity;
														lf_availDataClose="";
													     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
													}else{
														lf_availDataType="2";
													     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
														lf_availDataStart=oldValidity;
													     //S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
														lf_availDataClose=validity;
													}
													$("#insuredIdDateType").val(lf_availDataType);
													$scope.insuredIdDateTypeSelect = lf_availDataType;
													var options_insured =$("#insuredIdDateType option:selected");
													$scope.insuredCreTypeName=options_insured.text();
													myFactory.initDateUtil('insuredIdDate','');
													
													//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
													$scope.photoMainData.lf_availDataStart=lf_availDataStart;
													myFactory.initDateUtil('insuredIdDateStart',lf_availDataStart);
													if(lf_availDataType=="1"){
														$scope.photoMainData.lf_availDataClose="";
														myFactory.initDateUtil('insuredIdDate','');
														$("#insuredIdDate").val("");
													}else{
														$scope.photoMainData.lf_availDataClose=lf_availDataClose;
														myFactory.initDateUtil('insuredIdDate',lf_availDataClose);
													}
													
													//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end 
												//信易通OCR身份证有效期校验 add by lb 20220926 start
												}else if("BF"==role){
													var bf_availDataType="";
													var bf_availDataStart="";
													var bf_availDataClose="";
													if(validity=='长期' || validity=='终身'){
														bf_availDataType="1";
														bf_availDataStart=oldValidity;
													}else{
														bf_availDataType="2";
														bf_availDataStart=oldValidity;
														bf_availDataClose=validity;
													}
													var benefitList = $scope.benefiIdPtData;
													if (benefitList != null && benefitList != "" && benefitList.length > 0) {
														for (var i = 0; i < benefitList.length; i++) {
															if ($scope.curentPtBfName == benefitList[i].name) {
																benefitList[i].availDataType = bf_availDataType;
																benefitList[i].availDataTypeCN = bf_availDataType == '2' ? '年期' : '长期';
																benefitList[i].availDataStart = bf_availDataStart;//有效期起始日
																benefitList[i].availDataClose = bf_availDataClose;//有效期截至日
																break;
															}
														}
													}
												}
												//信易通OCR身份证有效期校验 add by lb 20220926 end
												setIdCardPic(curentPtId,curentPtTypeName,$scope.bigPic);
												$scope.smallPic="";
												$scope.bigPic="";
											}
												else {
													myFactory.alert('注意','证件反面区域只能扫描身份证反面，请重新扫描！','info');
													return
												}
											}
										}
									}
								},result.data);
							}
							
							
							
							
							
						}
					}
				//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
				},{canModify : true});				
				//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
				/*if(result.data.ok){
					if(result.data.isFront){
						//身份证正面
						var name=result.data.Name;
						var sex=result.data.Sex;
						var birthday=result.data.Birthday;
						var id =result.data.Id;//证件号码
						var address=result.data.Address;
						var idCardSmallPic=result.data.smallPic;
						var idCardBigPic=result.data.bigPic;
						checkAndSetIdcardInfo(id,name,sex,birthday,role,curentPtId,curentPtTypeName,idCardBigPic);
					}else{
						//身份证反面
						var validity=result.data.Validity;//有效期
						var idCardSmallPic=result.data.smallPic;
						var idCardBigPic=result.data.bigPic;
						
						//存在有效期为长期的情况：
						if("OW"==role){
							var ow_availDataType="";
							var ow_availDataClose="";
							if(validity=='长期' || validity=='终身'){
								ow_availDataType="1";
							}else{
								ow_availDataType="2";
								ow_availDataClose=validity;
							}
							$("#holderIdDateType").val(ow_availDataType);
							$scope.holderIdDateTypeSelect = ow_availDataType;
							var options_holder =$("#holderIdDateType option:selected");
							$scope.holderCreTypeName=options_holder.text();

							if(ow_availDataType=='2'){
								if(ow_availDataClose!="" && ow_availDataClose!=null && ow_availDataClose!=undefined){
									$scope.photoMainData.ow_availDataClose=ow_availDataClose;
									myFactory.initDateUtil('holderIdDate',ow_availDataClose);
								}else{
									myFactory.initDateUtil('holderIdDate','');
								}
							}else{
								myFactory.initDateUtil('holderIdDate','');
							}
						}else if("LF"==role){
							var lf_availDataType="";
							var lf_availDataClose="";
							if(validity=='长期' || validity=='终身'){
								lf_availDataType="1";
							}else{
								lf_availDataType="2";
								lf_availDataClose=validity;
							}
							$("#insuredIdDateType").val(lf_availDataType);
							$scope.insuredIdDateTypeSelect = lf_availDataType;
							var options_insured =$("#insuredIdDateType option:selected");
							$scope.insuredCreTypeName=options_insured.text();
							myFactory.initDateUtil('insuredIdDate','');
							
							if(lf_availDataType=='2'){
								if(lf_availDataClose!="" && lf_availDataClose!=null && lf_availDataClose!=undefined){
									$scope.photoMainData.lf_availDataClose=lf_availDataClose;
									myFactory.initDateUtil('insuredIdDate',lf_availDataClose);
								}else{
									myFactory.initDateUtil('insuredIdDate','');
								}
							}
						}
						setIdCardPic(curentPtId,curentPtTypeName,idCardBigPic);
					}
				}*/
			}

			//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
			function checkCradValidity(validity,role){
			//	var cacheDateClose;
				if("OW"==role){
					if ( typeof photoMainData.ow_availDataClose == 'number' ){
						photoMainData.ow_availDataClose = photoMainData.ow_availDataClose.toString();
						photoMainData.ow_availDataClose = photoMainData.ow_availDataClose.substring(0,4) +"-"+photoMainData.ow_availDataClose.substring(4,6)+"-"+photoMainData.ow_availDataClose.substring(6,8)
					}
					if(validity != photoMainData.ow_availDataClose && photoMainData.ow_availDataClose != ''){
						return false;
					}
				}else if("LF"==role){
					if ( typeof photoMainData.lf_availDataClose == 'number' ) {
						photoMainData.lf_availDataClose = photoMainData.lf_availDataClose.toString();
						photoMainData.lf_availDataClose = photoMainData.lf_availDataClose.substring(0,4) +"-"+photoMainData.lf_availDataClose.substring(4,6)+"-"+photoMainData.lf_availDataClose.substring(6,8)
					}
					if(validity != photoMainData.lf_availDataClose && photoMainData.lf_availDataClose != ''){
						return false;
					}
				}else if("BF"==role){
					var bf_availDataClose="";
					var bf_name="";
					var benefitList=photoMainData.benefitList;
					if(benefitList!=null & benefitList!="" && benefitList.length>0){
						for(var i=0;i < benefitList.length;i++){
							bf_name=benefitList[i].name;
							if($scope.curentPtBfName==bf_name){
								bf_availDataClose=benefitList[i].availDataClose;
								break;
							}
						}
					}
					if(validity != bf_availDataClose && bf_availDataClose != '' && bf_availDataClose != '99999999'){
						return false;
					}
				}
				return true;
			}
			//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
			function checkCradOldValidity(oldValidity,role){
				    if("OW"==role){
						if ( typeof photoMainData.ow_availDataStart == 'number' ){
							photoMainData.ow_availDataStart = photoMainData.ow_availDataStart.toString();
						}
						if(photoMainData.ow_availDataStart.indexOf("-") == -1){
							photoMainData.ow_availDataStart = photoMainData.ow_availDataStart.substring(0,4) +"-"+photoMainData.ow_availDataStart.substring(4,6)+"-"+photoMainData.ow_availDataStart.substring(6,8);
						}
						if(oldValidity != photoMainData.ow_availDataStart && photoMainData.ow_availDataStart != ''){
							return false;
						}
					}else if("LF"==role){
						if ( typeof photoMainData.lf_availDataStart == 'number' ) {
							photoMainData.lf_availDataStart = photoMainData.lf_availDataStart.toString();
							//photoMainData.lf_availDataStart = photoMainData.lf_availDataStart.substring(0,4) +"-"+photoMainData.lf_availDataStart.substring(4,6)+"-"+photoMainData.lf_availDataClose.substring(6,8)
						}
						if(photoMainData.lf_availDataStart.indexOf("-") == -1 ){
							photoMainData.lf_availDataStart = photoMainData.lf_availDataStart.substring(0,4) +"-"+photoMainData.lf_availDataStart.substring(4,6)+"-"+photoMainData.ow_availDataStart.substring(6,8);
						}
						if(oldValidity != photoMainData.lf_availDataStart && photoMainData.lf_availDataStart != ''){
							return false;
						}
						
					}else if("BF"==role){
						var bf_availDataStart="";
						var bf_name="";
						var benefitList=photoMainData.benefitList;
						if(benefitList!=null & benefitList!="" && benefitList.length>0){
							for(var i=0;i < benefitList.length;i++){
								bf_name=benefitList[i].name;
								if($scope.curentPtBfName==bf_name){
									bf_availDataStart=benefitList[i].availDataStart;
									break;
								}
							}
						}
						if(oldValidity != bf_availDataStart && bf_availDataStart != ''){
							return false;
						}
						
					}
					return true;
				}
			//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
			
			//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
			//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
			function checkAndSetIdcardInfo(idNo,role,curentPtId,curentPtTypeName,idCardBigPic,curentPtBfName){
//				function checkAndSetIdcardInfo(idNo,name,sex,birthday,role,curentPtId,curentPtTypeName,idCardBigPic,curentPtBfName){
						console.log("queryIdCardInfoByIdNo begin...........");
				//alert("checkAndSetIdcardInfo");
				if(checkFlag10=="Y" && "BF"!=role){
//					if("男"==sex){
//						sex="M";
//					}else{
//						sex="F";
//					}
//					birthday=birthday.replace(/-/g,"");
					if("OW"==role){
						//alert("idNo="+idNo);
						//alert("ow_idNo="+photoMainData.ow_idNo);
						if(idNo!=photoMainData.ow_idNo){
							//setIdCardPic(curentPtId,curentPtTypeName,idCardBigPic);
							myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认!","info");
							return false;
						}else{
//							if(name==photoMainData.ow_name && sex==photoMainData.ow_sex && birthday==photoMainData.ow_birthday){
								setIdCardPic(curentPtId,curentPtTypeName,idCardBigPic);
//							}else{
//								//setIdCardPic(curentPtId,curentPtTypeName,idCardBigPic);
//								myFactory.alert("","证件信息与客户身份信息不一致，请办理身份信息变更！","info");
//								return false;
//							}
						}
					}else if("LF"==role){
						if(idNo!=photoMainData.lf_idNo){
							myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
							return false;
						}else{
//							if(name==photoMainData.lf_name && sex==photoMainData.lf_sex && birthday==photoMainData.lf_birthday){
								setIdCardPic(curentPtId,curentPtTypeName,idCardBigPic);
//							}else{
//								myFactory.alert("","证件信息与客户身份信息不一致，请办理身份信息变更！","info");
//								return false;
//							}
						}
					}
				}else{
					var isCheckFlag=false;
					if("OW"==role){
						if(idNo==photoMainData.ow_idNo){
							isCheckFlag=true;
						}else{
							myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
							return false;
						}
					}else if("LF"==role){
						if(idNo==photoMainData.lf_idNo){
							isCheckFlag=true;
						}else{
							myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
							return false;
						}
					}else if("BF"==role){
						isCheckFlag=false;//受益人留影界面不需要与后台校验了
						var bf_name="";
						var bf_sex="";
						var bf_idNo="";
						var bf_birthDay="";
//						if("男"==sex){
//							sex="M";
//						}else{
//							sex="F";
//						}
						var benefitList=photoMainData.benefitList;
						if(benefitList!=null & benefitList!="" && benefitList.length>0){
							for(var i=0;i < benefitList.length;i++){
								bf_name=benefitList[i].name;
								/*姓名、name
								性别：sex  F M
								idType 1
								idNo
								birthday 2018-01-01*/
								if(curentPtBfName==bf_name){
//									bf_sex=benefitList[i].sex;
									bf_idNo=benefitList[i].idNo;
//									bf_birthDay=benefitList[i].birthDay;
									break;
								}
							}
						}
						
						if(idNo!=bf_idNo){
							myFactory.alert("","留影证件信息与客户信息/当次变更后信息不一致，请确认！","info");
							return false;
						}else{
//							if(name==bf_name && sex==bf_sex && birthday==bf_birthDay){
								setIdCardPic(curentPtId,curentPtTypeName,idCardBigPic);
//							}else{
//								myFactory.alert("","证件信息与客户身份信息不一致，请办理身份信息变更！","info");
//								return false;
//							}
						}
						
					}
					if(isCheckFlag){
						setIdCardPic(curentPtId,curentPtTypeName,idCardBigPic);
//						var token=sessionStorage.getItem("token");
//						var timestamp=myFactory.getTimetamp();
//						var sfis= "token-timestamp";
//						var signStr="token="+token+"&timestamp="+timestamp;
//						var sign = myFactory.hex(signStr);
//						$http({
//							method: 'GET',
//							url: app.domain + 'common/queryIdCardInfoByIdNo.action',
//							params: {'secuityno':idNo,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
//						}).then(function successCallback(response) {
//							if (response.data.success) {
//								var secuityno = response.data.data.secuityno;
//								if(secuityno != "" && secuityno != null && secuityno != undefined){
//									var surname = response.data.data.surname;
//									var cltsex = response.data.data.cltsex;
//									if("M"==cltsex){
//										cltsex="男";
//									}else{
//										cltsex="女";
//									}
//									var cltdob = response.data.data.cltdob;
//									if("99999999"==cltdob){
//										cltdob="长期";
//									}
//									console.log("secuityno="+secuityno+",surname="+surname+",cltsex="+cltsex+",cltdob="+cltdob);
//									birthday=birthday.replace(/-/g,"");
//									if(name==surname && sex==cltsex && birthday==cltdob){
//										setIdCardPic(curentPtId,curentPtTypeName,idCardBigPic);
//									}else{
//										//setIdCardPic(curentPtId,curentPtTypeName,idCardBigPic);
//										myFactory.alert("","证件信息与客户身份信息不一致，请办理身份信息变更！","info");
//									}
//								}else{
//									myFactory.alert("","证件信息与客户身份信息不一致，请办理身份信息变更！","info");
//								}
//							}
//						}, function errorCallback(response) {
//							console.log("do queryIdCardInfoByIdNo error");
//						});
					}
				}
			}
			//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
		
			function setIdCardPic(curentPtId,curentPtTypeName,resultImage){
				//设置图片
				$("#img_"+curentPtTypeName+"_"+curentPtId).css('display','inline');
				$("#photo_cover_"+curentPtId).css('display','none');
				$("#text_cover_"+curentPtId).css('display','none');
				$("#img_"+curentPtTypeName+"_"+curentPtId).attr('src','data:image/gif;base64,'+resultImage);
				$("#"+curentPtTypeName+"_"+curentPtId).val(resultImage);
				$("#delImg_"+curentPtId).css('display','inline');
			}
			//S2018051403895_信易通人证合一及活体检测项目需求 add by rqyang 20180711 end
			//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 start
			/**
			 * 扫描银行卡信息
			 */
			$scope.scanBankCardInfo = function (context_id,typeName) {
				if($scope.isPhotoOpenFlag){
					$scope.isPhotoOpenFlag=false;
					setTimeout(function() {
						$scope.isPhotoOpenFlag=true;
					}, 350);
				}else{
					return false;
				}
				if($("#img_"+typeName+"_"+context_id).attr("src")){
					return false;
				}
				//移动端
				cordova.sino.getBankCardInfo(function(result){
					if(result.success){
						if(!result.data.exit){
							if(appVersion==="IOS"){
								if(result.data.ok){
									var cardNumber=result.data.CardNumber;//卡号									
									var val = result.data.bigPic;//拍照数据
									//alert(CardNumber+","+CardInsName+","+BankCardType);
									cardNumber = cardNumber.replace(/ /g,"");
									var tempNumber = $scope.photoMainData.bankInfoAcc;
									if (cardNumber != tempNumber ){
											myFactory.alert('','留影银行账户信息与当次录入的账户信息不一致，请确认','info');
											return;
									}
									$("#img_"+typeName+"_"+context_id).css('display','inline');
									$("#photo_cover_"+context_id).css('display','none');
									$("#text_cover_"+context_id).css('display','none');
									$("#img_"+typeName+"_"+context_id).attr('src','data:image/gif;base64,'+val);
									$("#"+typeName+"_"+context_id).val(val);
									$("#delImg_"+context_id).css('display','inline');
								} else{
									myFactory.alert('','扫描银行卡信息失败:'+result.data.errormsg,'info');
								}
							}else{
								var val = result.data.bigPic;//拍照数据
								result.data.bigPic="";
								cordova.sino.confirmBankCardInfo(function(result){
									if(result.success){
										if(result.data.ok){
											var cardNumber=result.data.CardNumber;//卡号
											cardNumber = cardNumber.replace(/ /g,"");
												var tempNumber = $scope.photoMainData.bankInfoAcc;
												if (cardNumber != tempNumber ){
													myFactory.alert('','留影银行账户信息与当次录入的账户信息不一致，请确认','info');
													return;
												}
											
											$("#img_"+typeName+"_"+context_id).css('display','inline');
											$("#photo_cover_"+context_id).css('display','none');
											$("#text_cover_"+context_id).css('display','none');
											$("#img_"+typeName+"_"+context_id).attr('src','data:image/gif;base64,'+val);
											$("#"+typeName+"_"+context_id).val(val);
											$("#delImg_"+context_id).css('display','inline');
										}
									}else{
										myFactory.alert('','扫描银行卡信息失败:'+result.data.errormsg,'info');
									}
								},result.data)
							}
						}
					}else{
						//sino.alert("扫描银行卡信息失败:"+result.data.errormsg);
						myFactory.alert('','扫描银行卡信息失败:'+result.data.errormsg,'info');
					}
				}
				/*信易通3.0 S2019012807164信易通OCR识别功能————留影签名页面 银行卡选择扫描或拍照方式调整  yangyan 20190828 start*/
				,{canModify : true}
				/*信易通3.0 S2019012807164信易通OCR识别功能————留影签名页面 银行卡选择扫描或拍照方式调整  yangyan 20190828 end*/
				);
			}//扫描银行卡信息函数END
			
			if(photoMainData.bankInfoImg){
				$("#img_bankPt_506a").css('display','inline');
				$("#photo_cover_506a").css('display','none');
				$("#text_cover_506a").css('display','none');
				$("#img_bankPt_506a").attr('src','data:image/gif;base64,'+photoMainData.bankInfoImg);
				$("#bankPt_506a").val(photoMainData.bankInfoImg);
				$("#delImg_506a").css('display','inline');
			}
			
			//S2019012807164 - 信易通OCR识别功能 add by csf 20190412 end
			
			/*S2019012807164信易通OCR识别功能————留影签名页面 银行卡选择扫描或拍照方式调整  jiyongchang 20190513 start*/
					
			$scope.bankphotoflag = function (context_id,typeName) {
				myFactory.goBankPhotoFlag(bankPhotoSuccess,bankPhotoError); 
			}
			function bankPhotoSuccess(response){
				/*myFactory.alert('','进入response','info');*/
	            var resCode = response.data.returnCode;
	            /*0 使用银行卡拍照（旧）takePictures        1使用银行卡OCR扫描（新）scanBankCardInfo*/
	           /* myFactory.alert('','进入response：'+resCode,'info');*/
	             if ( resCode == '0'){
	            	 $scope.takePictures("506a","bankPt");	            	 
	             }else{
	            	 $scope.scanBankCardInfo("506a","bankPt");	
	            	 
	             }
	        }
	        function bankPhotoError(response){   	
	        	   myFactory.alert("","获取银行卡拍照开关异常，请稍后重试","info");
	               myFactory.loadingHide();
	        	   return;
	       }
			
	        /*S2019012807164信易通OCR识别功能————留影签名页面 银行卡选择扫描或拍照方式调整  jiyongchang 20190513 end*/
	        
	        //S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 upate by huanghk 20231115 start
	        function changeAvailDataStart(dataStart,dataEnd,birthDay){
				dataStart = dataStart.replaceAll('-', '');
				dataEnd=dataEnd.replaceAll('-', '');
				birthDay=birthDay.replaceAll('-', '');
				//计算年龄（有效期起始日-出生日期）
				var age = getTimeDifference(dataStart,birthDay);
				
				//截止日+1天
				var dataEndT = new Date(dataEnd.substring(0,4)+'/'+dataEnd.substring(4,6)+'/'+dataEnd.substring(6,8));
				dataEndT = new Date(dataEndT.getTime() + 24*60*60*1000);
				var endYear = dataEndT.getFullYear();
				var endMonth = dataEndT.getMonth() + 1;  
				var endDay = dataEndT.getDate();
				endMonth = endMonth < 10 ? '0' + endMonth : endMonth;
	            endDay = endDay < 10 ? '0' + endDay : endDay;
				var endMD = endMonth.toString() + endDay.toString();
				var dataEndDateTStr = endYear.toString() + endMD;
				var period = getTimeDifference(dataEndDateTStr,dataStart);
				
				if(age<18){
					if(period!=5){
						return false;
					}
				}else{
					if(period!=10){
						return false;
					}
				}

				var dataStartMD = dataStart.substring(4,8);
				var dataEndMD = dataEnd.substring(4,8);
				if(dataStartMD!="0229" && dataEndMD!="0229"){		
					if(dataStartMD!=dataEndMD && dataStartMD!=endMD){
						return false;
					}				
				}
				return true;
			}

			
			function getTimeDifference(dataStart,dataEnd){         
				var returnYear;  
				
				var dataStart = dataStart.replaceAll('-', '');
				var dataStartYear = dataStart.substring(0,4); 
				var dataStartMonth = dataStart.substring(4,6);   
				var dataStartDay = dataStart.substring(6,8); 
				
				var dataEnd=dataEnd.replaceAll('-', '');
				var dataEndYear = dataEnd.substring(0,4); 
				var dataEndMonth = dataEnd.substring(4,6);
				var dataEndDay = dataEnd.substring(6,8);
				
				if(dataStartYear == dataEndYear){  
					returnYear = 0;//同年
				} else {  
					var yearDiff = dataStartYear - dataEndYear ; //年之差  
					if(yearDiff > 0){  
						if(dataStartMonth == dataEndMonth) {  
							var dayDiff = dataStartDay - dataEndDay;//日之差  
							if(dayDiff < 0) {  
								returnYear = yearDiff - 1;  
							} else {  
								returnYear = yearDiff ;  
							}  
						} else {  
							var monthDiff = dataStartMonth - dataEndMonth;//月之差  
							if(monthDiff < 0) {  
								returnYear = yearDiff - 1;  
							} else {  
								returnYear = yearDiff ;  
							}  
						}  
					} else {  
						returnYear = -1;//返回-1 表示日期输入错误
					}  
				}  
				return returnYear;
			}
			//S2023103127804-粤金办发〔2023〕27号-外国人永久居留身份证规则调整系统需求 upate by huanghk 20231115 end
		}]);

		//指针弹窗
		app.directive('infoid',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/content_base_info.html'+app.clearCache,
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('指令完成');
				}
			}
		});
		
		//S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 start
		String.prototype.replaceAll = function(s1, s2) {
			return this.replace(new RegExp(s1, "gm"), s2);
		}
		//S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 end

		
})(app)